Cweili / svelte-fa

Tiny FontAwesome component for Svelte
https://cweili.github.io/svelte-fa/
MIT License
399 stars 25 forks source link

Is property `icon` required in `<FaLayers />`? #238

Closed macabeus closed 1 year ago

macabeus commented 1 year ago

When running npm run check, it says that it's missing the icon property:

Error: Type '{ size: "2x"; }' is not assignable to type 'IntrinsicAttributes & { class?: string; id?: string; style?: string; icon: IconDefinition; size?: "xs" | "sm" | "lg" | `${number}x`; color?: string; fw?: boolean; ... 12 more ...; swapOpacity?: boolean; }'.
  Property 'icon' is missing in type '{ size: "2x"; }' but required in type '{ class?: string; id?: string; style?: string; icon: IconDefinition; size?: "xs" | "sm" | "lg" | `${number}x`; color?: string; fw?: boolean; pull?: "left" | "right"; scale?: string | number; ... 10 more ...; swapOpacity?: boolean; }'. (ts)
    >
      <FaLayers size="2x">
        <Fa

But on svelte-fa readme, it looks like that this property isn't required. Also, the application looks like working fine.

Is it a wrong type definition?

Since I'm using svelte-kit, I needed to do this trick:

declare module 'svelte-fa/src/fa.svelte' {
  import Fa from 'svelte-fa/src/index.js';
  export default Fa;
}

declare module 'svelte-fa/src/fa-layers.svelte' {
  import FaLayers from 'svelte-fa/src/index.js';
  export default FaLayers;
}
Cweili commented 1 year ago

No. https://github.com/Cweili/svelte-fa/blob/master/src/fa-layers.d.ts

Maybe you should declare types as:

declare module 'svelte-fa/src/fa.svelte' {
  import Fa from 'svelte-fa/src/fa.d.ts';
  export default Fa;
}

declare module 'svelte-fa/src/fa-layers.svelte' {
  import FaLayers from 'svelte-fa/src/fa-layers.d.ts';
  export default FaLayers;
}
macabeus commented 1 year ago

Thanks for the reply, but vscode shows errors in the proposed code.

An import path cannot end with a '.d.ts' extension. Consider importing 'svelte-fa/src/fa-layers.js' instead.ts(2691)

image
Cweili commented 1 year ago

Try importing separately and no need to declare types: https://github.com/Cweili/svelte-fa/issues/239#issuecomment-1319364670

Cweili commented 1 year ago

This issue is closed due to not being active. Please feel free to open it again (for the author) or create a new one and reference this (for others) if you have further questions.