Skip to content

Getting an error for using FormattedHTMLMessage #79

@udayrajMT

Description

@udayrajMT
  • version:
  • node version: 12
  • yarn version: 1.22
  • react-intl version: 2.9.0

Do you want to request a feature or report a bug?:
bug.
(would be a feature if this functionality is missing altogether)

What is the current behavior?:
When using FormattedHTMLMessage to parse the following string -
Sample message string : Hello <span class='bold'>'{name}'</span>

I'm getting an 'unexpected token' error.

yarn run v1.22.4
$ extract-messages -l=messages -o dist -d en './src/components/**/!(*.test).js'
SyntaxError: [React Intl] Message failed to parse. See: https://formatjs.io/docs/icu-syntax
SyntaxError: Expected "#", "'", "\n", "{", argumentElement, double apostrophes, end of input, or tagElement but "<" found. (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (/project/node_modules/@babel/core/lib/transformation/file/file.js:248:12)
    at NodePath.buildCodeFrameError (/project/node_modules/@babel/traverse/lib/path/index.js:144:21)
    at getICUMessageValue (/project/node_modules/extract-react-intl-messages/node_modules/babel-plugin-react-intl/dist/index.js:66:27)
    at evaluateMessageDescriptor (/project/node_modules/extract-react-intl-messages/node_modules/babel-plugin-react-intl/dist/index.js:113:26)
    at processMessageObject (/project/node_modules/extract-react-intl-messages/node_modules/babel-plugin-react-intl/dist/index.js:388:38)
    at Array.forEach (<anonymous>)
    at PluginPass.CallExpression (/project/node_modules/extract-react-intl-messages/node_modules/babel-plugin-react-intl/dist/index.js:415:38)
    at newFn (/project/node_modules/@babel/traverse/lib/visitors.js:179:21)
    at NodePath._call (/project/node_modules/@babel/traverse/lib/path/context.js:55:20)
    at NodePath.call (/project/node_modules/@babel/traverse/lib/path/context.js:42:17)
error Command failed with exit code 1.

What is the expected behavior?:
Expecting this to be extracted like the other messages.

Suggested solution:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions