Skip to content

Commit 72abe48

Browse files
authored
docs(api-hmr): update hmr hot type (#7787)
1 parent 1d468c8 commit 72abe48

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

docs/guide/api-hmr.md

+18-12
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,27 @@ Vite exposes its manual HMR API via the special `import.meta.hot` object:
1010

1111
```ts
1212
interface ImportMeta {
13-
readonly hot?: {
14-
readonly data: any
13+
readonly hot?: ViteHotContext
14+
}
15+
16+
interface ViteHotContext {
17+
readonly data: any
1518

16-
accept(): void
17-
accept(cb: (mod: any) => void): void
18-
accept(dep: string, cb: (mod: any) => void): void
19-
accept(deps: string[], cb: (mods: any[]) => void): void
19+
accept(): void
20+
accept(cb: (mod: any) => void): void
21+
accept(dep: string, cb: (mod: any) => void): void
22+
accept(deps: readonly string[], cb: (mods: any[]) => void): void
2023

21-
prune(cb: () => void): void
22-
dispose(cb: (data: any) => void): void
23-
decline(): void
24-
invalidate(): void
24+
dispose(cb: (data: any) => void): void
25+
decline(): void
26+
invalidate(): void
2527

26-
on(event: string, cb: (...args: any[]) => void): void
27-
}
28+
// `InferCustomEventPayload` provides types for built-in Vite events
29+
on<T extends string>(
30+
event: T,
31+
cb: (payload: InferCustomEventPayload<T>) => void
32+
): void
33+
send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
2834
}
2935
```
3036

0 commit comments

Comments
 (0)