chore(types): augment ImportMeta with glob signature

`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<string, { default: string }>`). The call sites'
existing `mod.default ?? mod` narrowing still works.

Net renderer typecheck: 29 → 26 (-3 errors).
This commit is contained in:
simoleo89
2026-05-10 21:46:10 +02:00
parent ddb7222b66
commit e82d3e03be
+17
View File
@@ -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: <url> }`; 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: <T = { default: string }>(pattern: string, options?: { eager?: boolean; import?: string }) => Record<string, T>;
}