From 0c46c1064b737ebe2feed556c5f5226ad5bae27f Mon Sep 17 00:00:00 2001 From: alex8088 <244096523@qq.com> Date: Sun, 30 Jul 2023 17:27:04 +0800 Subject: [PATCH] chore(types): add Vite importMeta types --- node.d.ts | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/node.d.ts b/node.d.ts index 5d71b10..ac60e42 100644 --- a/node.d.ts +++ b/node.d.ts @@ -37,3 +37,65 @@ declare namespace NodeJS { readonly ELECTRON_RENDERER_URL?: string } } + +// Refer to Vite's ImportMeta type declarations +// + +interface ImportMetaEnv { + MODE: string + DEV: boolean + PROD: boolean +} + +interface ImportGlobOptions { + /** + * 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 + /** + * 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 + */ + ( + glob: string | string[], + options?: ImportGlobOptions + ): (Eager extends true ? true : false) extends true ? Record : Record Promise> + (glob: string | string[], options?: ImportGlobOptions): Record Promise> + (glob: string | string[], options: ImportGlobOptions): Record +} + +interface ImportMeta { + url: string + readonly env: ImportMetaEnv + glob: ImportGlobFunction +}