fork-ts-checker-webpack-plugin giving errors about @types and Mocha

Created on 14 Jul 2018  路  5Comments  路  Source: TypeStrong/fork-ts-checker-webpack-plugin

I'm using ts-loader and fork-fs-checker-webpack-plugin in a project, and it's complaining about node_modules/@types, for example:

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.

And also about it, describe, expect, etc. with errors such as:

TS2304: Cannot find name 'describe'.
TS2304: Cannot find name 'expect'.

I have tried to exclude the directories in tsconfig.json:

"exclude": [
  "node_modules",
  "node_modules/@types"
]

And (part of) my 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()
]

Versions:

"webpack": "^4.16.0"
"ts-loader": "^4.4.2"
"fork-ts-checker-webpack-plugin": "^0.4.3"

Most helpful comment

@theborowski I'm now using 3.0.1, but for me, I think the error was because of an issue with the versions of the libraries. I removed everything (node_modules and yarn.lock) and re-installed everything, and that specific issue was gone.

Actually, now that I think about it, I could say my issue was solved, so I'm going to close the issue :)

All 5 comments

@farzadmf What version of typescript are you using? I'm experiencing a somewhat similar issue with greensock after upgrading typescript from 2.7.1 to 3.0.1.

ERROR in /temp/proj/src/node_modules/@types/greensock/index.d.ts
ERROR in /temp/proj/src/node_modules/@types/greensock/index.d.ts(49,15):
TS2300: Duplicate identifier 'Animation'.

@theborowski I'm now using 3.0.1, but for me, I think the error was because of an issue with the versions of the libraries. I removed everything (node_modules and yarn.lock) and re-installed everything, and that specific issue was gone.

Actually, now that I think about it, I could say my issue was solved, so I'm going to close the issue :)

The code below should ensure that the errors from within node_modules will not be reported.

tsconfig.json

{
    compilerOptions: {
         skipLibCheck: true
   }
}

Please reopen this issue it still exists.
Every time I add for example jodit, it complains about source files in node_modules
I already tested skipLibChek, exclude and nothing helps.

I don't know why it is doing something different than normal tsc (which works fine)

Could you provide a reproduction repository?

Was this page helpful?
0 / 5 - 0 ratings