【发布时间】:2020-09-01 02:16:50
【问题描述】:
我正在尝试为HtmlWebpackPlugin 编写 typescript 声明文件,但无法正常工作。
HtmlWebpackPlugin 默认导出是类HtmlWebpackPlugin 的构造函数。我打算这样使用它。
somefile.ts
import * as HtmlWebpackPlugin from 'html-webpack-plugin'
new HtmlWebpackPlugin({..some options...})
我尝试将其定义如下
shim.d.ts
/// <reference path="./shim.d.ts"/>
declare module 'html-webpack-plugin' {
interface Options {
title: string,
filename: string,
template: string,
inject: (boolean | 'head' | 'body'),
favicon: string,
hash: boolean,
cache: boolean,
showErrors: boolean,
chunks: any,
chunksSortMode: ('none' | 'auto' | 'dependency'),
excludeChunks: any,
xhtml: boolean
}
class HtmlWebpackPlugin {
constructor(options: Options);
}
export default ???
}
我想知道在???这里填写什么。我尝试导出HtmlWebpackPlugin、typeof HtmlWebpackPlugin,但没有任何效果。它给了我以下类型错误。
【问题讨论】:
标签: node.js typescript