Files
multica/packages/views/assets.d.ts
Jiang Bohan f26bdffaf2 fix(provider-logo): handle Next.js vs vite PNG import shape divergence
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.
2026-05-28 15:58:28 +08:00

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;
}