Definitelytyped: [@types/terser-webpack-plugin] Support for webpack 5

Created on 15 Oct 2020  ·  4Comments  ·  Source: DefinitelyTyped/DefinitelyTyped

@types/terser-webpack-plugin doesn't support webpack 5 types which are now generated by webpack itself.

node_modules/@types/terser-webpack-plugin/index.d.ts:7:10 - error TS2305: Module '"../../webpack/types"' has no exported member 'Plugin'.

7 import { Plugin } from 'webpack';
           ~~~~~~
  • [x] I tried using the @types/terser-webpack-plugin package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @Danscho, @peterblazejewicz

Most helpful comment

I have another error message popping up in the webpack config file, when using terser-webpack-plugin 5.0.0 with webpack 5:

Type 'TerserPlugin' is not assignable to type '"..." | WebpackPluginInstance | ((this: Compiler, compiler: Compiler) => void)'.
  Type 'TerserPlugin' is not assignable to type '(this: Compiler, compiler: Compiler) => void'.
    Type 'TerserPlugin' provides no match for the signature '(this: Compiler, compiler: Compiler): void'.ts(2322)

Anyone else having this issue?

All 4 comments

@peterblazejewicz already created a pull request.
Please see: #48794.
This should resolve your issue.

I have another error message popping up in the webpack config file, when using terser-webpack-plugin 5.0.0 with webpack 5:

Type 'TerserPlugin' is not assignable to type '"..." | WebpackPluginInstance | ((this: Compiler, compiler: Compiler) => void)'.
  Type 'TerserPlugin' is not assignable to type '(this: Compiler, compiler: Compiler) => void'.
    Type 'TerserPlugin' provides no match for the signature '(this: Compiler, compiler: Compiler): void'.ts(2322)

Anyone else having this issue?

From what I can tell the issue is that the latest version of @types/terser-webpack-plugin, even after #48794, still specifies @types/webpack@* as dependency, which resolves to [email protected]. It seems that this dependency is somehow added implicitly by @DefinitelyTyped, as I can't find it in the package.json. Do we maybe have to add webpack@5 as a dependency to prevent this?

webpack@5 also doesn't export Plugin any more, but e.g. WebpackPluginInstance.

@buschtoens
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/48857
there was same issue with webpack 5.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zzzen picture Zzzen  ·  3Comments

Loghorn picture Loghorn  ·  3Comments

tyv picture tyv  ·  3Comments

JWT
svipas picture svipas  ·  3Comments

jbreckmckye picture jbreckmckye  ·  3Comments