diff --git a/guide/api-hmr.md b/guide/api-hmr.md index 18c509ab..109f0643 100644 --- a/guide/api-hmr.md +++ b/guide/api-hmr.md @@ -10,7 +10,10 @@ Vite は特別な `import.meta.hot` オブジェクトを介して、マニュ ```ts twoslash import type { ModuleNamespace } from 'vite/types/hot.d.ts' -import type { InferCustomEventPayload } from 'vite/types/customEvent.d.ts' +import type { + CustomEventName, + InferCustomEventPayload, +} from 'vite/types/customEvent.d.ts' // ---cut--- interface ImportMeta { @@ -32,15 +35,18 @@ interface ViteHotContext { prune(cb: (data: any) => void): void invalidate(message?: string): void - on<T extends string>( + on<T extends CustomEventName>( event: T, cb: (payload: InferCustomEventPayload<T>) => void, ): void - off<T extends string>( + off<T extends CustomEventName>( event: T, cb: (payload: InferCustomEventPayload<T>) => void, ): void - send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void + send<T extends CustomEventName>( + event: T, + data?: InferCustomEventPayload<T>, + ): void } ```