9

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

还有关于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"
4

0 回答 0