我在一个项目中使用ts-loader和fork-fs-checker-webpack-plugin,并且抱怨node_modules/@types
,例如:
ERROR in D:/temp/temp-vscode/temp-electron/application-volume- change/node_modules/@types/react/index.d.ts
ERROR in D:/temp/temp-vscode/temp-electron/application-volume-change/node_modules/@types/react/index.d.ts(2288,19):
TS2320: Interface 'Element' cannot simultaneously extend types 'ReactElement<any>' and 'ReactElement<any>'.
Named property 'type' of types 'ReactElement<any>' and 'ReactElement<any>' are not identical.
还有it
,describe
,expect
等错误,例如:
TS2304: Cannot find name 'describe'.
TS2304: Cannot find name 'expect'.
我试图排除tsconfig.json
中的目录:
"exclude": [
"node_modules",
"node_modules/@types"
]
还有我的webpack.config
的一部分:
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
...
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
happyPackMode: true,
},
},
],
},
]
...
plugins: [
new ForkTsCheckerWebpackPlugin()
]
版本:
"webpack": "^4.16.0"
"ts-loader": "^4.4.2"
"fork-ts-checker-webpack-plugin": "^0.4.3"