我正在寻找一种方法来覆盖现有的库定义文件,以包含一些修复程序。这是目录结构:
node_modules/
preact/
dist/
preact.d.ts <-- this file is wrong, I'd like to use my own
types/
preact.d.ts <-- use this file instead
无论如何要么完全覆盖preact附带的那个,要么排除该文件被拾取?现在它显示Duplicate identifier
到处都是。
如果有帮助,请点击我的tsconfig.json
文件:
{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
"sourceMap": false,
"lib": [
"dom",
"es5",
"es6",
"es7"
],
"sourceRoot": "src",
"outDir": "dist",
"jsx": "react",
"jsxFactory": "h",
"noImplicitAny": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"allowSyntheticDefaultImports": true,
"noEmitOnError": true
},
"include": [
"src/**/*",
"types/**/*"
],
"exclude": [
"node_modules/preact/dist/preact.d.ts"
],
"baseUrl": ".",
"paths": {
"*": [
"types/*"
]
}
}
谢谢!
答案 0 :(得分:0)
Woops!看起来我在这里找到了答案:Exclude/overwrite npm-provided typings
paths
应位于compilerOptions
下,而不是顶级。