diff --git a/docs/guide/api-hmr.md b/docs/guide/api-hmr.md index 46eabab04e8868..1cba492e6613c1 100644 --- a/docs/guide/api-hmr.md +++ b/docs/guide/api-hmr.md @@ -10,21 +10,27 @@ Vite exposes its manual HMR API via the special `import.meta.hot` object: ```ts interface ImportMeta { - readonly hot?: { - readonly data: any + readonly hot?: ViteHotContext +} + +interface ViteHotContext { + readonly data: any - accept(): void - accept(cb: (mod: any) => void): void - accept(dep: string, cb: (mod: any) => void): void - accept(deps: string[], cb: (mods: any[]) => void): void + accept(): void + accept(cb: (mod: any) => void): void + accept(dep: string, cb: (mod: any) => void): void + accept(deps: readonly string[], cb: (mods: any[]) => void): void - prune(cb: () => void): void - dispose(cb: (data: any) => void): void - decline(): void - invalidate(): void + dispose(cb: (data: any) => void): void + decline(): void + invalidate(): void - on(event: string, cb: (...args: any[]) => void): void - } + // `InferCustomEventPayload` provides types for built-in Vite events + on( + event: T, + cb: (payload: InferCustomEventPayload) => void + ): void + send(event: T, data?: InferCustomEventPayload): void } ```