From e82d3e03be7f5387253ec03b05f63a35a88ce57f Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Sun, 10 May 2026 21:46:10 +0200 Subject: [PATCH] chore(types): augment ImportMeta with glob signature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `AssetManager.loadRoomImages()` and friends use `import.meta.glob('./assets/...', { eager: true })` to bundle PNG assets via Vite, but TypeScript doesn't see `glob` on ImportMeta without pulling `vite/client` — which we avoid here so the React client (which has its own asset declarations) keeps full control. src/globals.d.ts adds just the `glob` signature, typed for the eager image case (`Record`). The call sites' existing `mod.default ?? mod` narrowing still works. Net renderer typecheck: 29 → 26 (-3 errors). --- src/globals.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/globals.d.ts diff --git a/src/globals.d.ts b/src/globals.d.ts new file mode 100644 index 0000000..3c288ac --- /dev/null +++ b/src/globals.d.ts @@ -0,0 +1,17 @@ +/** + * Vite injects `import.meta.glob(pattern, options)` at runtime but TS + * doesn't see it without `vite/client` types — and we don't want to pull + * the full `vite/client` because it overrides asset module declarations + * the consumer (`../Nitro-V3`) owns. Augment `ImportMeta` with just the + * glob signature. + * + * For eager image globs (the only flavor `AssetManager` uses) Vite + * returns `{ default: }`; the call sites then narrow with + * `mod.default ?? mod` for back-compat. The return type below covers + * the eager case directly. Default generic is typed loosely to allow + * `(mod.default ?? mod) as string` patterns. + */ +interface ImportMeta +{ + glob: (pattern: string, options?: { eager?: boolean; import?: string }) => Record; +}