-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Which package?
ts-transform
Describe the bug
This occurred when I upgraded to 8.1.0 and beyond of @formatjs/cli-lib.
We use extract() in our tests to verify that all our intl strings actually exists in the code.
const foundTranslations = await extract(files, {
idInterpolationPattern: '[sha512:contenthash:base64:6]'
});
Prior to 8.1.0 we were relying on erroneous keys simply being skipped. But after this it throws as soon as an erroneous key is found.
I think I have narrowed it down to this commit here: 16fdf64#diff-25baed40cc703386cb8cbece67f207cf31ee23a36ff94c0ffead2f32aede87d2
The commit is well documented and it seems to me I can revert to the old behaviour by adding throws: false.
The comment here in this test alludes to that: 16fdf64#diff-9c026660716a6d9efef0b08c7288f031230963af8edb13184b7ca2e8c013ef18R4
const foundTranslations = await extract(files, {
idInterpolationPattern: '[sha512:contenthash:base64:6]',
throws: false, <-- I thought adding this would resume previous behavior
});
However, what I think happens is that though the throws flag is handled here
formatjs/packages/cli-lib/src/extract.ts
Line 220 in 16fdf64
| if (throws) { |
The promise.all is still rejected because an error was thrown, resulting in rawResults being empty evne though several good messages was extracted.
formatjs/packages/cli-lib/src/extract.ts
Line 211 in 16fdf64
| rawResults = await Promise.all( |
First time looking at this repository so apologise if I have misunderstood anything.
I don't know what is the desired behaviour here from your side. But I don't think there is any way I can work around this change from our part 🤔 We are relying on getting what could be extracted, and handling those messages who did not ourselves.
To Reproduce
Codesandbox URL
Will provide if required
Expected behavior
I expect that setting throws: false will allow me to use extract as before that stricter id interpolation checks were added. We use sporadic dynamic keys, so I cannot rewrite to always using string literals for extraction
Desktop (please complete the following information):
- OS: iOS, linux
- Browser: JSdom