Feature request
Typescript should be made aware of the module.hot
property.
There is a ts lint error when trying to access module.hot
.
Property 'hot' does not exist on type 'NodeModule'
.
module
is defined out of the box as a NodeModule in ~/Library/Caches/typescript/2.7/node_modules/@types/node/index.d.ts
which is probably installed by vscode.
Installing @types/webpack-env
fixes the ts lint error.
It does this by extending the NodeModule type.
interface NodeModule extends __WebpackModuleApi.Module {}
Perhaps there should be a @types/parcel-env
module.
Decided to try out parcel as I have previously been using webpack a lot. I am happy with it but parcel looked very interesting, and simpler in many ways.
I'm also trying Preact, and immediately fell into the hot module issue documented here https://github.com/parcel-bundler/parcel/issues/261.
I am using the jsdoc functionality to use typescript in vscode to validate my js and jsx files.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.6.2 |
| Node | 8.10.0 |
| Yarn | 1.5.1 |
| Operating System | Mac OSX High Sierra 10.13.3 |
| VSCode | 1.21.1 |
declare var module : {
hot : {
accept(path?:string, callback?:() => void): void;
};
};
Thankyou @FDiskas, or since I'm using js with jsdoc and have d.ts files in a typings folder, maybe this
declare global {
interface NodeModule {
hot : {
accept(path?: string, callback?: () => void): void
}
}
}
export { }
This is what I'm doing with window
, I'm not sure if it's the perfect way of doing this.
This should be documented
Most helpful comment
@types/parcel-env
merged to DefinitelyTyped!