Skip to content

Commit

Permalink
docs(api-hmr): note intellisense for import.meta.hot (#12184)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Feb 24, 2023
1 parent 8477b07 commit 8f57a18
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/guide/api-hmr.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ if (import.meta.hot) {
}
```
## IntelliSense for TypeScript
Vite provides type definitions for `import.meta.hot` in [`vite/client.d.ts`](https://github.com/vitejs/vite/blob/main/packages/vite/client.d.ts). You can create an `env.d.ts` in the `src` directory so TypeScript picks up the type definitions:
```ts
/// <reference types="vite/client" />
```
## `hot.accept(cb)`
For a module to self-accept, use `import.meta.hot.accept` with a callback which receives the updated module:
Expand Down

0 comments on commit 8f57a18

Please sign in to comment.