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

[regression >3.1.1] Type generics annotation do not get forwarded to FormattedMessage #1412

Closed
emmenko opened this issue Aug 12, 2019 · 3 comments · Fixed by #1413
Closed

Comments

@emmenko
Copy link
Contributor

emmenko commented Aug 12, 2019

This commit 660a546 changed the exported component message component to be wrapped with injectIntl.

However, I believe that this change broke the TS generics, as the type of the values field does not get forwarded anymore.

Before I could do:

<FormattedMessage<
  Record<string, (msg: React.ReactNodeArray) => JSX.Element>
>
  {...messages.paragraph1}
  values={{
    a: msg => (
      <a
        href={SUPPORT_PORTAL_URL}
        target="_blank"
        rel="noopener noreferrer"
      >
        {msg}
      </a>
    ),
  }}
/>

But now it breaks because the generic type that I pass gets ignored

image

Can the component be rewritten using react hooks?

@emmenko
Copy link
Contributor Author

emmenko commented Aug 12, 2019

@longlho what do you think? What is your preference for this? I guess we should either remove the HOC or forward the types.

I can open a PR if you point me in the right direction.

@longlho
Copy link
Member

longlho commented Aug 12, 2019

unfortunately we can't fully use hooks yet per #1290 (comment) so forwarding type would be best rn. PR's always welcome!

@emmenko
Copy link
Contributor Author

emmenko commented Aug 12, 2019

I see, thanks for the info. I'll look into forwarding types then.

longlho pushed a commit that referenced this issue Aug 13, 2019
* refactor: avoid wrapping components with injectIntl

* test: adjust message matchers for node@12 native APIs
longlho pushed a commit that referenced this issue Aug 30, 2019
* refactor: avoid wrapping components with injectIntl

* test: adjust message matchers for node@12 native APIs
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 a pull request may close this issue.

2 participants