-
Notifications
You must be signed in to change notification settings - Fork 836
Add TypeScript types to the React integration #228
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
Conversation
Is there a way to disable that on PR builds? |
Hi @j-f1, and thanks for this! I agree that we shouldn't need |
Also, are there conventions around unit testing TypeScript types? I just want to be sure that if we do any heavy refactoring of how the icon components are generated we can ensure that we haven't broken the types. Thanks again! |
Here's a gist showing them in use. I pulled the commit in this PR in and tested it locally, and made this. (I was testing it in a Storybook). It'd be a great help if we can get this merged. (In the interim, I've compiled the types for 8.0.0 into a |
Probably define some Typescript examples with strict compiler options and check if the examples compile? |
The typical example for JS projects shipping TS declarations is essentially what moment.js has setup:
|
I’ll try to get to this today or tomorrow. |
Although this is a little confusing, it allows you to import `{iconsByName}` and use as both a value (`iconsByName[foo]`) and as a type (`(icon: keyof iconsByName) => boolean`).
Also export `OcticonProps`.
This should be ready to go. Are there any other comments? |
Friendly ping @shawnbot :) |
Hi @j-f1, this is on my list for today or tomorrow! I have every intention of getting this merged this week and deployed ASAP. Thank you for your patience, and all the hard work! ❤️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rad, thank you so much @j-f1!
This adds TypeScript types to
@githubprimer/octicons-react
, which allows TypeScript projects to install the module and immediately start using it without installing a separate package. IMO this package should have the types integrated because they need to be generated while building the package to get the most current list of names to export.The TypeScript types include the exact values for each icon’s
size
property, and callinggetIconByName
with a literal string representing an icon will return the correct type of that icon.Ref desktop/desktop#5185.