Skip to content

Conversation

@morellodev
Copy link
Contributor

@morellodev morellodev commented Apr 5, 2022

At the moment, the country prop is typed as string, while the set of legal country codes is limited.

We can leverage the countryCodes array to build up a CountryCode type that we can use to better type the country prop. Moreover, we can export it for external usage.

Note that the proposed solution is not breaking for existing codebases (we loosely type country to be of type CountryCode | Omit<string, CountryCode>).

@stephenway stephenway self-requested a review April 6, 2022 16:29
Copy link
Owner

@stephenway stephenway left a comment

Choose a reason for hiding this comment

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

This is awesome, thanks @morellodev!

@stephenway stephenway merged commit 45ae436 into stephenway:master Apr 6, 2022
@morellodev morellodev deleted the better-ts-support branch April 6, 2022 19:45
stephenway added a commit that referenced this pull request Apr 27, 2022
added stricter typing for country prop
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.

2 participants