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

No exported type MessageFormatElement #2559

Closed
hannahatwork opened this issue Feb 3, 2021 · 1 comment
Closed

No exported type MessageFormatElement #2559

hannahatwork opened this issue Feb 3, 2021 · 1 comment
Labels

Comments

@hannahatwork
Copy link

Which package?

react-intl

Describe the bug

There is no exported type for compiled messages.

To Reproduce

Implement the code in the "message distribution" part of the docs and try to add a type for props.messages.

Reproducible Steps/Repo

Generate some compiled translations using the formatjs command. Resulting object looks roughly like:

{
  "2x0bZ6": [
    {
      "type": 0,
      "value": "There "
    },
    {
      "offset": 0,
      "options": {
        "=0": {
          "value": [
            {
              "type": 0,
              "value": "are no clients"
            }
          ]
        },
        "=1": {
          "value": [
            {
              "type": 0,
              "value": "is 1 client"
            }
          ]
        },
// etc...

Then implement the code in the "message distribution" step of the FormatJS docs. The messages prop of the AuthProvider expects the following type: (JSX attribute) messages?: Record<string, string> | Record<string, MessageFormatElement[]> | undefined but no MessageFormatElement type is exported by react-intl.

Expected behavior

There should be an exported type that can be used to type the compiled messages that are generated by formatjs.

Screenshots

Screen Shot 2021-02-03 at 4 04 55 PM

Note: It looks like there used to be some type guidance in the docs, but it was wrong, so it was removed. See #1900

@2ico
Copy link

2ico commented Feb 9, 2024

This is still an issue when using createIntl from '@formatjs/intl'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants