@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';
~~~~~~
@types/terser-webpack-plugin
package and had problems.Definitions by:
in index.d.ts
) so they can respond.@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.
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:
Anyone else having this issue?