fork-ts-checker-webpack-plugin给出有关@types和Mocha的错误

时间:2018-07-14 13:18:59

标签: typescript webpack webpack-4 ts-loader

我在一个项目中使用ts-loaderfork-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.

还有itdescribeexpect等错误,例如:

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"

0 个答案:

没有答案