Skip to content

Cannot use defineMessages on an object reference #90

@MattKunze

Description

@MattKunze

I think this might be similar to #81, but I'm getting compiler errors instead of undefined keys.

Passing a predefined object reference to defineMessages fails, I'm guessing the code isn't following the reference in the Babel AST and instead assuming an object is directly defined:

import { defineMessages } from "react-intl.macro"
const messages = {
  key: { id: "key", defaultMessage: "Default Message" }
}
defineMessages(messages)

this fails with:

TypeError: react-intl.macro: properties.map is not a function Learn more: https://www.npmjs.com/package/react-intl.macro
    at Array.map (<anonymous>)

My use case is I have a shared library where the messages are defined, but the build process isn't working correctly for the sub module (different issues with Rollup). So I'm trying to import the messages in my app and forward them to defineMessages so they get picked up when I build the available translations.

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