Skip to content

Commit 23e23c8

Browse files
committed
feat(types): type hints for hmr events
resolve vitejs#1885 vitejs/vite@95424b2 の反映です。
1 parent 8ae4b5b commit 23e23c8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

guide/api-hmr.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ Vite は特別な `import.meta.hot` オブジェクトを介して、マニュ
1010

1111
```ts twoslash
1212
import type { ModuleNamespace } from 'vite/types/hot.d.ts'
13-
import type { InferCustomEventPayload } from 'vite/types/customEvent.d.ts'
13+
import type {
14+
CustomEventName,
15+
InferCustomEventPayload,
16+
} from 'vite/types/customEvent.d.ts'
1417

1518
// ---cut---
1619
interface ImportMeta {
@@ -32,15 +35,18 @@ interface ViteHotContext {
3235
prune(cb: (data: any) => void): void
3336
invalidate(message?: string): void
3437

35-
on<T extends string>(
38+
on<T extends CustomEventName>(
3639
event: T,
3740
cb: (payload: InferCustomEventPayload<T>) => void,
3841
): void
39-
off<T extends string>(
42+
off<T extends CustomEventName>(
4043
event: T,
4144
cb: (payload: InferCustomEventPayload<T>) => void,
4245
): void
43-
send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
46+
send<T extends CustomEventName>(
47+
event: T,
48+
data?: InferCustomEventPayload<T>,
49+
): void
4450
}
4551
```
4652

0 commit comments

Comments
 (0)