Skip to content

Commit

Permalink
Merge pull request #93 from tony19/vitejs/vite@da632bf
Browse files Browse the repository at this point in the history
refactor(types): bundle client types (#9966)
  • Loading branch information
tony19 committed Sep 24, 2022
2 parents b0e5769 + 22af9c8 commit b5be9e4
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions docs/guide/api-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -595,12 +595,21 @@ It is possible to type custom events by extending the `CustomEventMap` interface
```ts
// events.d.ts
import 'vite/types/customEvent'
import 'vite'
import 'vite/client/types'

declare module 'vite/types/customEvent' {
interface CustomEventMap {
'custom:foo': { msg: string }
// 'event-key': payload
}
interface MyCustomEventMap {
'custom:foo': { msg: string }
// 'event-key': payload
}

// extend interface for server-side
declare module 'vite' {
interface CustomEventMap extends MyCustomEventMap {}
}

// extend interface for client-side
declare module 'vite/client/types' {
interface CustomEventMap extends MyCustomEventMap {}
}
```

0 comments on commit b5be9e4

Please sign in to comment.