Ale*_*tov 8 symlink types typechecking typescript pnpm
据我从教程中了解到, pnpm.registry.npmjs.org在 下创建符号链接和其他条目点node_modules。我的项目已经启动typescript,我需要@types输入node_modules. 但这@types也有在node_modules/.registry.npmjs.org/@types。所以我收到如下错误:
/node_modules/.registry.npmjs.org/@types/jquery/3.3.5/node_modules/@types/jquery/index.d.ts(32,14): error TS2300: Duplicate identifier 'jQuery'.
...和
/node_modules/@types/jquery/index.d.ts(28,14): error TS2300: Duplicate identifier 'jQuery'.
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"es5",
"dom",
"es2015.promise"
],
"experimentalDecorators": true,
"sourceMap": true,
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"scripts",
"src/contracts"
]
}
Run Code Online (Sandbox Code Playgroud)
有什么想法如何解决吗?
对我来说"typeRoots": ["./node_modules/@types"]有效。
默认情况下tsc将在所有文件夹中查找类型node_modules/@types。
您可以通过调用 来测试正在包含哪些文件tsc --listFiles。
我认为因为这个文件本身包含在内typescript,那么它还将包含 pnpm repo store 中的所有文件node_modules/.pnpm/@types。
xxx/node_modules/.pnpm/typescript@3.9.7/node_modules/typescript/lib/lib.es5.d.ts
Run Code Online (Sandbox Code Playgroud)
就我而言,我有多个版本的 React 可供阅读。