tabler / tabler-icons

A set of over 5500 free MIT-licensed high-quality SVG icons for you to use in your web projects.
https://tabler.io/icons
MIT License
18.03k stars 898 forks source link

Export a type for Icons? #1045

Closed naughton closed 6 months ago

naughton commented 6 months ago

the type signature for all react icons is ForwardRefExoticComponent<Omit<IconProps, "ref"> & RefAttributes<Icon>> and Icon is not exported.

maybe you could export a type like this for a better "dx"?

import { ForwardRefExoticComponent, RefAttributes, FunctionComponent } from "react";

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

Then this type can be used where people want to allow their own typescript types to have TablerIcon typed values.

e.g.

import { type TablerIcon, IconTrash } from "@tabler/icons-react";

type MenuItem = {
    title: string;
    icon: TablerIcon;
}

const deleteMenuItem: MenuItem = { title: "Delete", icon: IconTrash }
lukasbash commented 6 months ago

I think there was a type Icon exported before the latest release. Might make sense to re-export it?

codecalm commented 6 months ago

Icon type are exported in 3.0.2