Skip to content

Commit

Permalink
docs(api-hmr): update hmr hot type (#7787)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Apr 21, 2022
1 parent 1d468c8 commit 72abe48
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions docs/guide/api-hmr.md
Expand Up @@ -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<T extends string>(
event: T,
cb: (payload: InferCustomEventPayload<T>) => void
): void
send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
}
```

Expand Down

0 comments on commit 72abe48

Please sign in to comment.