Skip to content

Commit

Permalink
fix(@formatjs/ts-transformer): ignore msgs without id & defaultMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Long Ho committed May 8, 2020
1 parent 3b496ea commit 903beed
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/ts-transformer/src/transform.ts
Expand Up @@ -130,10 +130,10 @@ function extractMessageDescriptor(
}
});
// We extracted nothing
if (!Object.entries(msg).find(([_, v]) => v)) {
if (!msg.defaultMessage && !msg.id) {
return;
}
if (!msg.id && overrideIdFn) {
if (!msg.id && msg.defaultMessage && overrideIdFn) {
switch (typeof overrideIdFn) {
case 'string':
msg.id = interpolateName(
Expand Down
Expand Up @@ -183,6 +183,7 @@ class Foo extends react_1.Component {
defaultMessage: \\"Hello Nurse!\\"
}),
invalid: this.props.intl.formatMessage(objectPointer),
invalid2: this.props.intl.formatMessage({ id, defaultMessage, description: 'asd' })
};
return (react_1.default.createElement(\\"div\\", null,
react_1.default.createElement(\\"h1\\", null, msgs.header),
Expand Down Expand Up @@ -375,7 +376,7 @@ Object {
name: intl.formatMessage({
id: \\"HELLO.undefined.6.undefined\\",
defaultMessage: \\"layer2\\"
})
}),
});
",
"msgs": Array [
Expand Down
Expand Up @@ -22,6 +22,11 @@ class Foo extends Component {
description: 'Another message',
}),
invalid: this.props.intl.formatMessage(objectPointer),
invalid2: this.props.intl.formatMessage({
id,
defaultMessage,
description: 'asd',
}),
};

return (
Expand Down

0 comments on commit 903beed

Please sign in to comment.