我正在尝试升级到 webpack 5,但我现在收到一个类型错误
尝试使用 TsconfigPathsPlugin。 (npm tsconfig-paths-webpack-plugin)。
我需要这个插件,以便我可以解析文件中的别名路径。您可以在此处查看使用示例:https://betterprogramming.pub/the-right-usage-of-aliases-in-webpack-typescript-4418327f47fa
resolve: {
extensions: [...],
// resolve aliases from tsconfig.server.json
plugins: [
new TsconfigPathsPlugin({ // type error here
configFile: './tsconfig.server.json',
}),
],
alias: {...},
},
我收到以下错误:Type 'TsconfigPathsPlugin' is not assignable to type '"..." | ResolvePluginInstance'.
Type 'TsconfigPathsPlugin' is not assignable to type 'ResolvePluginInstance'.
Types of property 'apply' are incompatible.
我觉得这不是一个普遍存在的问题,因为我看不到任何提及它在其他地方,但我本以为我至少可以找到一个人
遇到了同样的问题。
最佳答案
我遇到了同样的问题,但今天我发现该插件在以下版本下有效。
"tsconfig-paths-webpack-plugin": "^3.5.1",
"webpack": "^5.51.1",
关于typescript - TsconfigPathsPlugin 类型与 webpack 5 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66502671/