Open
Description
Messages which are defined using defineMessages
inside standalone objects are not extracted by the parser. For example:
enum ItemStatus {
OPENED = 'opened',
CLOSED = 'closed',
}
const standaloneMessages: {[key in ItemStatus]: Message} = {
[ItemStatus.OPENED]: {
defaultMessage: 'Opened',
id: 'app.itemStatus.Opened',
},
[ItemStatus.CLOSED]: {
defaultMessage: 'Closed',
id: 'app.itemStatus.Closed',
},
};
const messages = defineMessages(standaloneMessages);
The problem here is that the parser will not extract the messages, but the code is still valid TypeScript, so there is no way how I can restrict the usage of this pattern. The fix in code, to get it to work is simple, but should not be both approaches supported?
// This will be extracted by parser
const messages = defineMessages<ItemStatus>({
[ItemStatus.OPENED]: {
defaultMessage: 'Opened',
id: 'app.itemStatus.Opened',
},
[ItemStatus.CLOSED]: {
defaultMessage: 'Closed',
id: 'app.itemStatus.Closed',
},
});
(using typescript-react-intl
0.4.0)
Metadata
Metadata
Assignees
Labels
No labels