File tree 2 files changed +25
-9
lines changed
2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -595,12 +595,21 @@ It is possible to type custom events by extending the `CustomEventMap` interface
595
595
596
596
` ` ` ts
597
597
// events.d.ts
598
+ import 'vite'
598
599
import 'vite/client/types'
599
600
601
+ interface MyCustomEventMap {
602
+ 'custom:foo': { msg: string }
603
+ // 'event-key': payload
604
+ }
605
+
606
+ // extend interface for server-side
607
+ declare module 'vite' {
608
+ interface CustomEventMap extends MyCustomEventMap {}
609
+ }
610
+
611
+ // extend interface for client-side
600
612
declare module 'vite/client/types' {
601
- interface CustomEventMap {
602
- 'custom:foo': { msg: string }
603
- // 'event-key': payload
604
- }
613
+ interface CustomEventMap extends MyCustomEventMap {}
605
614
}
606
615
` ` `
Original file line number Diff line number Diff line change
1
+ import 'vite'
1
2
import 'vite/client/types'
2
3
4
+ interface MyCustomEventMap {
5
+ 'custom:foo' : { msg : string }
6
+ 'custom:remote-add' : { a : number ; b : number }
7
+ 'custom:remote-add-result' : { result : string }
8
+ }
9
+
10
+ declare module 'vite' {
11
+ interface CustomEventMap extends MyCustomEventMap { }
12
+ }
13
+
3
14
declare module 'vite/client/types' {
4
- interface CustomEventMap {
5
- 'custom:foo' : { msg : string }
6
- 'custom:remote-add' : { a : number ; b : number }
7
- 'custom:remote-add-result' : { result : string }
8
- }
15
+ interface CustomEventMap extends MyCustomEventMap { }
9
16
}
You can’t perform that action at this time.
0 commit comments