fix(types): move @lucide/svelte augmentation to module-context file
app.d.ts is a script-context declaration file. A `declare module 'x' {}`
in a script file is an ambient module declaration that completely replaces
the package's types — not an augmentation. This caused svelte-check to see
@lucide/svelte as exporting only IconProps, producing 1131 "class" errors
and 237 "no exported member" errors for every icon import.
Moving the augmentation to src/lucide-augment.d.ts with `export {}` makes
it a module file, so `declare module` becomes a proper augmentation that
merges with the package types. Result: Lucide errors drop from 1368 to 0.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
11
src/app.d.ts
vendored
11
src/app.d.ts
vendored
@@ -23,17 +23,6 @@ declare global {
|
|||||||
var native_app: any;
|
var native_app: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @lucide/svelte ≥ 0.577.0 dropped `class` from IconProps — it now derives props purely from
|
|
||||||
// SVGAttributes<SVGSVGElement>, which TypeScript types without `class` (uses `className` instead).
|
|
||||||
// Every <SomeIcon class="..." /> site in the codebase errors without this augmentation.
|
|
||||||
// If a future lucide update re-adds `class` natively, this becomes a harmless no-op.
|
|
||||||
// Root cause: @lucide/svelte 0.561.0 → 0.577.0 bump in chore commit 366c6629 (2026-03-10).
|
|
||||||
declare module '@lucide/svelte' {
|
|
||||||
interface IconProps {
|
|
||||||
class?: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stripe Buy Button web component — needed so Svelte templates accept the element without TS errors.
|
// Stripe Buy Button web component — needed so Svelte templates accept the element without TS errors.
|
||||||
declare module 'svelte/elements' {
|
declare module 'svelte/elements' {
|
||||||
interface IntrinsicElements {
|
interface IntrinsicElements {
|
||||||
|
|||||||
25
src/lucide-augment.d.ts
vendored
Normal file
25
src/lucide-augment.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// Module augmentation to restore `class` prop on @lucide/svelte IconProps.
|
||||||
|
//
|
||||||
|
// WHY this file exists and why it is separate from app.d.ts:
|
||||||
|
// @lucide/svelte ≥ 0.577.0 dropped `class` from IconProps (it now derives props purely from
|
||||||
|
// SVGAttributes<SVGSVGElement>, which TypeScript types without `class`). Every
|
||||||
|
// <SomeIcon class="..." /> in the codebase errors without this.
|
||||||
|
//
|
||||||
|
// WHY it cannot live in app.d.ts:
|
||||||
|
// app.d.ts is a script-context declaration file (no top-level import/export). A
|
||||||
|
// `declare module 'x' {}` in a script file is an AMBIENT MODULE DECLARATION that completely
|
||||||
|
// replaces the package's types — not an augmentation. That caused svelte-check to see
|
||||||
|
// @lucide/svelte as exporting only IconProps, making every icon import a "no exported member"
|
||||||
|
// error. Putting the declaration here with `export {}` makes this file a module, so
|
||||||
|
// `declare module` becomes a proper augmentation that merges with the package types.
|
||||||
|
//
|
||||||
|
// If a future lucide update re-adds `class` natively, this file becomes a harmless no-op.
|
||||||
|
// Root cause: @lucide/svelte 0.561.0 → 0.577.0 bump in chore commit 366c6629 (2026-03-10).
|
||||||
|
|
||||||
|
export {};
|
||||||
|
|
||||||
|
declare module '@lucide/svelte' {
|
||||||
|
interface IconProps {
|
||||||
|
class?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user