@types/terser-webpack-plugin 不支持现在由 webpack 本身生成的 webpack 5 类型。
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
包并且遇到了问题。Definitions by:
中的index.d.ts
)所以他们可以回应。@peterblazejewicz已经创建了一个拉取请求。
请参阅:#48794。
这应该可以解决您的问题。
当使用 terser-webpack-plugin 5.0.0 和 webpack 5 时,我在 webpack 配置文件中弹出另一个错误消息:
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)
还有谁有相同的问题吗?
据我所知,这个问题是@types/terser-webpack-plugin
的最新版本,即使在 #48794 之后,仍然指定@types/webpack@*
作为依赖项,它解析为[email protected]
。 似乎这种依赖是由@DefinitelyTyped以某种方式隐式添加的,因为我在package.json
找不到它。 我们是否必须添加webpack@5
作为依赖项来防止这种情况发生?
webpack@5
也不再导出Plugin
,但例如WebpackPluginInstance
。
@buschtoens
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/48857
webpack 5 也有同样的问题。
最有用的评论
当使用 terser-webpack-plugin 5.0.0 和 webpack 5 时,我在 webpack 配置文件中弹出另一个错误消息:
还有谁有相同的问题吗?