You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 06:56:19 +00:00
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:
Vendored
+17
@@ -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>;
|
||||
}
|
||||
Reference in New Issue
Block a user