Skip to content
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

feat(@formatjs/intl,react-intl): move IntlFormatter type parameters to methods #3858

Merged
merged 3 commits into from
Oct 11, 2022

Conversation

pyrocat101
Copy link
Member

@pyrocat101 pyrocat101 commented Oct 1, 2022

Fixes #3856
Fixes #3707

  1. Now IntlFormatters only take one type parameter TBase, which is the type constraint of the rich text element. For React, this will be React.ReactNode, requiring the rich text element to extend from React.ReactNode.
  2. formatMessage, $t, and formatList now types the type parameter T, which must satisfy T extends TBase. Doing so makes the formatter typing parametric to the callsite, which is more accurate than instantiating the type parameter on the IntlFormatters or its subtypes.

packages/intl/src/types.ts Outdated Show resolved Hide resolved
@pyrocat101
Copy link
Member Author

I probably butchered the typing of vue-intl. Anyone who knows Vue should probably review my change there.

packages/intl/src/list.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants