chore(types): add Vite importMeta types
This commit is contained in:
parent
6c590ad65b
commit
0c46c1064b
62
node.d.ts
vendored
62
node.d.ts
vendored
|
@ -37,3 +37,65 @@ declare namespace NodeJS {
|
||||||
readonly ELECTRON_RENDERER_URL?: string
|
readonly ELECTRON_RENDERER_URL?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Refer to Vite's ImportMeta type declarations
|
||||||
|
// <https://github.com/vitejs/vite/blob/main/packages/vite/types/importMeta.d.ts>
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
MODE: string
|
||||||
|
DEV: boolean
|
||||||
|
PROD: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportGlobOptions<Eager extends boolean, AsType extends string> {
|
||||||
|
/**
|
||||||
|
* Import type for the import url.
|
||||||
|
*/
|
||||||
|
as?: AsType
|
||||||
|
/**
|
||||||
|
* Import as static or dynamic
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
eager?: Eager
|
||||||
|
/**
|
||||||
|
* Import only the specific named export. Set to `default` to import the default export.
|
||||||
|
*/
|
||||||
|
import?: string
|
||||||
|
/**
|
||||||
|
* Custom queries
|
||||||
|
*/
|
||||||
|
query?: string | Record<string, string | number | boolean>
|
||||||
|
/**
|
||||||
|
* Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
exhaustive?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KnownAsTypeMap {
|
||||||
|
raw: string
|
||||||
|
url: string
|
||||||
|
worker: Worker
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportGlobFunction {
|
||||||
|
/**
|
||||||
|
* Import a list of files with a glob pattern.
|
||||||
|
*
|
||||||
|
* https://vitejs.dev/guide/features.html#glob-import
|
||||||
|
*/
|
||||||
|
<Eager extends boolean, As extends string, T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown>(
|
||||||
|
glob: string | string[],
|
||||||
|
options?: ImportGlobOptions<Eager, As>
|
||||||
|
): (Eager extends true ? true : false) extends true ? Record<string, T> : Record<string, () => Promise<T>>
|
||||||
|
<M>(glob: string | string[], options?: ImportGlobOptions<false, string>): Record<string, () => Promise<M>>
|
||||||
|
<M>(glob: string | string[], options: ImportGlobOptions<true, string>): Record<string, M>
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
url: string
|
||||||
|
readonly env: ImportMetaEnv
|
||||||
|
glob: ImportGlobFunction
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue