Definitelytyped: [@types/terser-webpack-plugin] 支持 webpack 5

创建于 2020-10-15  ·  4评论  ·  资料来源: DefinitelyTyped/DefinitelyTyped

@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';
           ~~~~~~
  • [x] 我尝试使用@types/terser-webpack-plugin包并且遇到了问题。
  • [x] 我尝试使用最新的稳定版 tsc。 https://www.npmjs.com/package/typescript
  • [x] [提及](https://github.com/blog/821-mention-somebody-they-re-notified) 作者(见Definitions by:中的index.d.ts )所以他们可以回应。

    • 作者: @Danscho ,@peterblazejewicz

最有用的评论

当使用 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)

还有谁有相同的问题吗?

所有4条评论

@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 也有同样的问题。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

jbreckmckye picture jbreckmckye  ·  3评论

Zzzen picture Zzzen  ·  3评论

csharpner picture csharpner  ·  3评论

victor-guoyu picture victor-guoyu  ·  3评论

svipas picture svipas  ·  3评论