tabler-icons icon indicating copy to clipboard operation
tabler-icons copied to clipboard

Icons don't match the exported type in @tabler/icons-react

Open th0th opened this issue 1 year ago • 4 comments

The icons in @tabler/icons-react don't seem to match the exported type Icon. Typescript shows an error like this:

TS2322: Type
ForwardRefExoticComponent<Omit<IconProps, "ref"> & RefAttributes<Icon>>
is not assignable to type Icon

Here I created an example on codesandbox. You can see the error in App.tsx on line 4. https://codesandbox.io/p/sandbox/gracious-fast-t362lv?file=%2Fsrc%2FApp.tsx

th0th avatar May 08 '24 11:05 th0th

Maybe related to https://github.com/tabler/tabler-icons/issues/1035 (which contains a possible workaround) 🤔

CHE1RON avatar May 14 '24 16:05 CHE1RON

Thank you @CHE1RON. I also created my custom type as a workaround. But getting rid of it, and using the type from the package would be easier :)

th0th avatar May 14 '24 16:05 th0th

Would you be willing to share your workaround? I experienced some issue in v3.3.0 and could give it a try 😉

CHE1RON avatar May 14 '24 16:05 CHE1RON

Would you be willing to share your workaround? I experienced some issue in v3.3.0 and could give it a try 😉

Of course. I use this one:

import { Icon, IconProps } from "@tabler/icons-react";
import { ForwardRefExoticComponent, RefAttributes } from "react";

export type TablerIcon = ForwardRefExoticComponent<Omit<IconProps, "ref"> & RefAttributes<Icon>>;

th0th avatar May 14 '24 17:05 th0th