mirror of
https://github.com/multica-ai/multica.git
synced 2026-06-17 11:48:42 +02:00
Next.js types PNG imports as StaticImageData ({ src, width, height });
vite/electron-vite types them as plain string. Component is consumed by
both apps/web (Next.js) and apps/desktop (electron-vite), so a single
type can't satisfy both — last CI failed apps/web typecheck.
Normalise via unknown at the import site so neither side's narrower
type causes the other side's branch to collapse to never. assets.d.ts
declares the union; the component derives a plain-string src once at
module load.
23 lines
713 B
TypeScript
23 lines
713 B
TypeScript
// Asset imports — modern bundlers resolve these to a URL at build time,
|
|
// but the exact shape differs between consumers:
|
|
// - electron-vite / plain vite: a `string` URL
|
|
// - Next.js (apps/web): a `StaticImageData` object with `.src`, plus
|
|
// width/height/blurDataURL
|
|
// Declare the union here so packages/views compiles in both contexts.
|
|
// Component code should normalise with `typeof x === "string" ? x : x.src`.
|
|
interface StaticImageAsset {
|
|
src: string;
|
|
height?: number;
|
|
width?: number;
|
|
blurDataURL?: string;
|
|
}
|
|
|
|
declare module "*.png" {
|
|
const src: string | StaticImageAsset;
|
|
export default src;
|
|
}
|
|
declare module "*.svg" {
|
|
const src: string | StaticImageAsset;
|
|
export default src;
|
|
}
|