Closed
Description
TypeScript Version: 3.9.0-dev.20200422
Search Terms:
- Signed numbers
- Object keys negative
- readonly negative key
- object key negative
- object key duplicate
- as const negative
- object key operand
- others...
Code
export const rotate = {
"-45": "test",
[-45]: "test" // Duplicate NOT detected
};
export const rotate2 = {
"45": "test",
[+45]: "test" // Duplicate NOT detected
};
export const rotate4 = {
"45": "test",
[45]: "test" // Duplicate detected
};
Expected behavior:
TypeScript should alert the user that there's a duplicated key.
Actual behavior:
Key duplication is not detected when the key is a number preceded by -
or +
.
Related Issues:
#37866 #38133 #37292
The bug seems to be there for a very long time (it has the same behavior on v2.4.1 on the playground).