//index.d.ts
declare global {
interface NodeRequire {
/** A special feature supported by webpack's compiler that allows you to get all matching modules starting from some base directory. */
context: (
directory: string,
useSubdirectories: boolean,
regExp: RegExp
) => any;
}
}
3条答案
按热度按时间7bsow1i61#
2018年的解决方案:
只需安装
webpack-env
的类型tcbh2hod2#
在tsconfig.json中,将其添加到types属性示例中:
rjee0c153#
除了以上解决方案外,您还可以手工为该功能增加一个接口,如下所示: