Skip to content

FormatJS Plugin doesn't support string concatenation #532

@vu-dao-93

Description

@vu-dao-93

I'm using the @swc/plugin-formatjs to transform react intl messages, and I face an error for message that have string concatenation

const message = defineMessage({
  defaultMessage: 'Hello ' + 'world'
});

the result would be

const message = defineMessage({
  defaultMessage: []
});

And throw this error

Error: Uncaught [Error: [@formatjs/intl] An `id` must be provided to format a message

I found this issue (formatjs/formatjs#2252) in formatjs, which indicates that string concatenation should be supported for defaultMessage. I think it should be added here as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions