Description
The exact match type in ChoicesOption is defined as: [digit: `${number}`]: string, which implies it should be used as follows:
const message = plural(count, {
'0': "No Books",
one: "# Book",
other: "# Books",
});
However, the correct key in MessageFormat syntax is be "=0" not just "0":
const message = plural(count, {
'=0': "No Books",
one: "# Book",
other: "# Books",
});
This works as expected, but leads to a type error. To fix that, the index signature in ChoicesOption should be [digit: `=${number}`]: string.
Verifications
Reproduction Steps
The following code, which works correctly, creates a type error:
const message = plural(count, {
'=0': "No Books",
one: "# Book",
other: "# Books",
});
Expected Behavior
There should not be a type error.
Macro Support
SWC with @lingui/swc-plugin
Lingui Version
5.3.3
Babel Version
Framework
Vite
Description
The exact match type in
ChoicesOptionis defined as:[digit: `${number}`]: string, which implies it should be used as follows:However, the correct key in MessageFormat syntax is be "=0" not just "0":
This works as expected, but leads to a type error. To fix that, the index signature in
ChoicesOptionshould be[digit: `=${number}`]: string.Verifications
Reproduction Steps
The following code, which works correctly, creates a type error:
Expected Behavior
There should not be a type error.
Macro Support
SWC with @lingui/swc-plugin
Lingui Version
5.3.3
Babel Version
Framework
Vite