Skip to content

Conversation

atomassoni
Copy link

This has been bothering me for years. I used the suggestion in this issue. #1269

What has changed:
The npm run build script creates a type file after the ionicons.json file has been created. IoniconName and IoniconSource are the types created from the json file. These types are also exported from index.ts so as to be available without using node_modules/ionicons/dist.

This change makes sure name is limited to actual available strings for icons.

(Stencil example)
If you're using type checking, this would be valid

<ion-icon name="heart" size="large" slot="start"></ion-icon>
This would not be valid
<ion-icon name="not-an-ionicon" size="large" slot="start"></ion-icon>

This will be a breaking change for some because they will have explicitly defined the name as "string". Also it must override Ionic's version (if using), although it works fine with it.

How to test
Just follow the same directions as usual, the npm build script creates the types.

What I did not address: any related types that are currently any or string but did not fall within the scope of the feature request.

Notes:
I used an .mjs script instead of a .ts script because there was a file called types.ts in scripts already.

I can definitely make it an actual .ts script with a different name, I had just been using this same script on my project and this was the quickest way.

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.

1 participant