Skip to content

feat: export types for icon names #1761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2025
Merged

feat: export types for icon names #1761

merged 1 commit into from
Jul 12, 2025

Conversation

johnf
Copy link
Collaborator

@johnf johnf commented Jun 7, 2025

No description provided.

@Prajwaltechversant
Copy link

does this pr fix this #1760, and update the glyphmaps file

Copy link
Collaborator

@vonovak vonovak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
there's a more direct way to obtain the icon names, as noted in review.

Thank you :)

@johnf
Copy link
Collaborator Author

johnf commented Jul 12, 2025

@vonovak thanks!

@johnf johnf force-pushed the export-icon-name-type branch from 0d3ea46 to d0acc50 Compare July 12, 2025 12:16
@johnf johnf merged commit 83a0b1b into master Jul 12, 2025
12 of 52 checks passed
@johnf johnf deleted the export-icon-name-type branch July 12, 2025 12:18
@abitling
Copy link

Instead of doing export type FontAwesome5ProLightIconName = keyof typeof lightGM; can't we do export type FontAwesome5ProLightIconName = ComponentProps<typeof LightIcon>['name'];

This is just a suggestion as the types exported are still not useful if we are creating a reusable component which renders the icon by accepting the icon name as prop to that component. In this case FontAwesome5ProLightIconName = ComponentProps<typeof LightIcon>['name']; works well.

@vonovak
Copy link
Collaborator

vonovak commented Jul 23, 2025

hello,

Instead of doing export type FontAwesome5ProLightIconName = keyof typeof lightGM; can't we do export type FontAwesome5ProLightIconName = ComponentProps<typeof LightIcon>['name'];

Those are the same thing. They are equivalent. Not sure I understand what you have in mind?

@abitling
Copy link

abitling commented Jul 23, 2025

@vonovak What I mean is, with the current implementation i.e export type FontAwesome5ProSolidIconName = keyof typeof solidGM; when I do the following I faced type errors.

import FontAwesome5Pro, {
    FontAwesome5ProSolidIconName,
} from '@react-native-vector-icons/fontawesome5-pro';

const IconComponent = ({
    name,
    size = 24,
    color = '#000',
}: {
    size: number;
    color: string;
    name: FontAwesome5ProSolidIconName;
}) => (
    <FontAwesome5Pro
        name={name}                //  This line throws type error "Type 'string | number | symbol' is not assignable to type 
                          //  '"function" | "font-awesome-logo-full" ... 2296 more ... | "zhihu"'
        size={size}
        color={color}
        iconStyle={'solid'}
    />
);

const IconComponentExample = () => (
    <IconComponent name='home' size={30} color='#000' />
);

export default IconComponentExample;

This error goes away when I do export type FontAwesome5ProSolidIconName = ComponentProps<typeof SolidIcon>['name'];. I hope this helps

@johnf
Copy link
Collaborator Author

johnf commented Jul 23, 2025

@abitling master has a fix and new release coming shortly

@abitling
Copy link

@abitling master has a fix and new release coming shortly

@johnf Thank you 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants