[英]Export webpack function in typescript
The webpack
docs show the type to be return from configuration function , but not the types of the parameters env
and argv
.该
webpack
文档显示类型从配置的回报功能,而不是类型的参数env
和argv
。 Currently I've to type them as any, however what are the actual types of env
and argv
?目前我必须输入它们,但是
env
和argv
的实际类型是什么?
const configuration = (env: any, argv: any): Configuration => ({
mode: 'production',
entry: './foo.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'foo.bundle.js',
},
...
});
They are both any
because they are both coming from the webpack cli arguments, so it is not possible to know the type in advance at compile time (unless you strictly know that you will always pass certain arguments and force the type to be what you declare it to be)它们都是
any
因为它们都来自 webpack cli 参数,所以不可能在编译时提前知道类型(除非你严格知道你总是会传递某些参数并强制类型为你声明的类型)它是)
Webpack Environment Variables docs may help to understand better. Webpack Environment Variables 文档可能有助于更好地理解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.