Skip to content

Type checking for node_modules #128

@maksimsemenov

Description

@maksimsemenov

I'm seeing a whole bunch of errors related to node_modules directory, like so:

ERROR in /Users/maksim/Documents/Elation/pumma/node_modules/typescript/lib/lib.dom.d.ts(15791,13):
TS2403: Subsequent variable declarations must have the same type.Variable 'onerror' must be of type '(this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any', but here has type 'ErrorEventHandler'.

ERROR in /Users/maksim/Documents/Elation/pumma/node_modules/typescript/lib/lib.dom.d.ts(15883,13):
TS2403: Subsequent variable declarations must have the same type.Variable 'self' must be of type 'WorkerGlobalScope', but here has type 'Window'.

ERROR in /Users/maksim/Documents/Elation/pumma/node_modules/typescript/lib/lib.dom.d.ts(15962,6):
TS2300: Duplicate identifier 'FormDataEntryValue'.

ERROR in /Users/maksim/Documents/Elation/pumma/node_modules/typescript/lib/lib.webworker.d.ts(1787,6):
TS2300: Duplicate identifier 'RequestMode'.

...

My webpack config:

module.exports = {
  context: __dirname,
  ...
  module: {
    rules: [
      {
        test: /\.(ts|tsx)$$/,
        use: [
          babelLoader,
          {
            loader: 'ts-loader',
            options: {
              transpileOnly: true,
            },
          },
        ],
        exclude: /node_modules/,
      }
    ],
  },
  resolve: {
    modules: [path.resolve(__dirname, './src'), 'node_modules'],
    extensions: ['.ts', '.tsx', '.js', '.jsx'],
    plugins: [new TsconfigPathsPlugin({ configFile: './tsconfig.json' })],
  },
  plugins: [
    new ForkTsCheckerWebpackPlugin(),
    ...
  ],
}

My tsconfig.json:

{
  "compilerOptions": {
    ...
    "baseUrl": "./src",
    ...
  },
  "include": ["./src/**/*"],
  "exclude": ["node_modules"]
}

I read through #116, but none of the recipes mentioned there worked for me.

Are there any other config options or any other details that I'm missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions