Cweili / svelte-fa

Tiny FontAwesome component for Svelte

Home Page:https://cweili.github.io/svelte-fa/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

macabeus opened this issue · comments

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

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

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

Try importing separately and no need to declare types: #239 (comment)

commented

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.