Skip to content

Commit

Permalink
fix: remove top-level imports in importMeta.d.ts, fixes augmentation (#…
Browse files Browse the repository at this point in the history
…6214)

Fixes #6194
Fixes #6211
Fixes #6206
Fixes #6205
  • Loading branch information
haoqunjiang committed Dec 21, 2021
1 parent 46b862a commit 6b8d94d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions packages/vite/types/importMeta.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { CustomEventName } from './customEvent'
import type {
ErrorPayload,
FullReloadPayload,
PrunePayload,
UpdatePayload
} from './hmrPayload'
// This file is an augmentation to the built-in ImportMeta interface
// Thus cannot contain any top-level imports
// <https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation>

/* eslint-disable @typescript-eslint/consistent-type-imports */

interface ImportMeta {
url: string
Expand All @@ -27,15 +25,24 @@ interface ImportMeta {
invalidate(): void

on: {
(event: 'vite:beforeUpdate', cb: (payload: UpdatePayload) => void): void
(event: 'vite:beforePrune', cb: (payload: PrunePayload) => void): void
(
event: 'vite:beforeUpdate',
cb: (payload: import('./hmrPayload').UpdatePayload) => void
): void
(
event: 'vite:beforePrune',
cb: (payload: import('./hmrPayload').PrunePayload) => void
): void
(
event: 'vite:beforeFullReload',
cb: (payload: FullReloadPayload) => void
cb: (payload: import('./hmrPayload').FullReloadPayload) => void
): void
(
event: 'vite:error',
cb: (payload: import('./hmrPayload').ErrorPayload) => void
): void
(event: 'vite:error', cb: (payload: ErrorPayload) => void): void
<T extends string>(
event: CustomEventName<T>,
event: import('./customEvent').CustomEventName<T>,
cb: (data: any) => void
): void
}
Expand Down

0 comments on commit 6b8d94d

Please sign in to comment.