ERROR in C:/phpStudy2018/PHPTutorial/WWW/Tms.Web/node_modules/@types/node/globals.d.ts(139,11):
139:11 Interface 'NodeRequire' cannot simultaneously extend types 'Require' and 'RequireFunction'.
Named property 'cache' of types 'Require' and 'RequireFunction' are not identical.
137 |
138 | // For backwards compability
> 139 | interface NodeRequire extends NodeJS.Require {}
| ^
140 | interface RequireResolve extends NodeJS.RequireResolve {}
141 | interface NodeModule extends NodeJS.Module {}
142 |
error in C:/phpStudy2018/PHPTutorial/WWW/Tms.Web/node_modules/@types/node/globals.d.ts
ERROR in C:/phpStudy2018/PHPTutorial/WWW/Tms.Web/node_modules/@types/node/globals.d.ts(139,11):
Run Code Online (Sandbox Code Playgroud)
我的环境是 vue.js + typescript。不知道我的配置有没有问题,或者第三方包有什么问题可以给我一些有用的建议吗谢谢
我遇到了一种情况,其中类型定义node_modules/@types正在安装自己的@types依赖项,而这些“嵌套的” @types与我的顶级@types冲突。
@types
|-angular //v1.5
|-angular-ui-bootstrap
|-node_modules
|-@types
|-angular //v1.6
Run Code Online (Sandbox Code Playgroud)
node_modules/@types/**/node_modules在tsconfig中?一个警告-我正在使用awesome-typescript-loader,这可能有一些限制。
我尝试过的
1- exclude属性中的文件glob 排除嵌套的node_modules
compilerOptions.exclude: '../node_modules/@types/**/node_modules'
Run Code Online (Sandbox Code Playgroud)
2- types明确声明
compilerOptions.types: ['angular', 'angular-ui-bootstrap']
Run Code Online (Sandbox Code Playgroud)
3-文件中的glob typeRoots排除嵌套的node_modules
compilerOptions.typeRoots: ['../node_modules/@types/**/!(node_modules)']
Run Code Online (Sandbox Code Playgroud)
我学到了什么
1-排除似乎不适用于@types
2-使用“类型”包含类型意味着包含其依赖的@types
3-typeRoots似乎不适用于文件glob(或者我写的glob错误)
有关:
https://github.com/Microsoft/TypeScript/issues/9731
https://github.com/Microsoft/TypeScript/issues/11917
https://github.com/s-panferov/awesome-typescript-loader/issues/492
tsconfig - 如何忽略一个特定的目录@类型/不管/ node_modules?
有关我的环境的详细信息
“ node”:“ 8.6.0”,“ typescript:” 2.8.3“,” awesome-typescript-loader“:” 5.0.0“,” webpack“:” 4.8.3“,