同样ts+react webpack配置了HotModuleReplacementPlugin()\,
为什么我module.hot 报错:TS2339: Property 'hot' does not exist on type 'NodeModule'.
webpack.config.js
new webpack.HotModuleReplacementPlugin(),
demo.ts
if(module.hot) {
{
// ...
}
TS2339: Property 'hot' does not exist on type 'NodeModule'.
已解决
解决办法:
1. if (module as any).hot {}
或者
2. yarn add @types/webpack.env -D
正常的,可以通过配置types文件或者直接写条件忽略