-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
Which package?
@formatjs/[email protected]
Describe the bug
When import attributes are used in the code, @formatjs/cli fails to extract messages despite tsc being able to successfully check the file.
The following errors are printed to console:
[@formatjs/cli] [WARN] Error: index.mts:2:43 - error TS1005: ';' expected.
2 import { doSomething } from './other.mjs' with { type: 'macro' }
~~~~
index.mts:2:48 - error TS1005: '(' expected.
2 import { doSomething } from './other.mjs' with { type: 'macro' }
~
index.mts:4:1 - error TS1005: ')' expected.
4 export const msg = defineMessage({
~~~~~~
To Reproduce
Codesandbox URL
https://stackblitz.com/edit/node-by7zrp?file=package.json
Reproducible Steps/Repo
- Create file
b.mtswith contents like:
export function myMacro() {
return { id: 'woo' }
}- Create file
a.mtswith contents like:
import { defineMessage } from '@formatjs/intl'
import { myMacro } from './b.mts' with { type: 'macro' }
export const greeting = defineMessage({
id: 'greeting',
defaultMessage: 'Hello, {name}!',
})
export const smthnElse = myMacro()- Try to extract messages from
a.mts
pnpm formatjs extract a.mts --out-file output.jsonExpected behavior
Extraction completes without errors and yields a file output.json with contents:
{
"greeting": {
"defaultMessage": "Hello, {name}!"
}
}Screenshots
N/A
Desktop (please complete the following information):
N/A
Smartphone (please complete the following information):
N/A
Additional context
N/D
bertho-zero