You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bug seems to be there for a very long time (it has the same behavior on v2.4.1 on the playground).
The text was updated successfully, but these errors were encountered:
rigwild
changed the title
Objects as const containing negative numbers as key breaks
Duplicated object key in const not detected when the key is a negative number
May 1, 2020
rigwild
changed the title
Duplicated object key in const not detected when the key is a negative number
Duplicated object key in const not detected when the key is a number preceded by - or +May 1, 2020
After some investigations, I found that the expression between the square brackets is not evaluated but just used as text.
I would like to fix this issue but I don't really know where to put the stuff. The fix could be something similar to how typescript handles constant enum values (computeConstantValue in checker.ts).
This looks a little bit more complicated for such cases:
letb=10consta={"46": 123,[b+46]: 1234,};
I think we can make it work by updating getPropertyNameForPropertyNameNode in utilities.ts but I'm not sure if it is the right place.
TypeScript Version:
3.9.0-dev.20200422
Search Terms:
Code
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+
.Playground Link
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).
The text was updated successfully, but these errors were encountered: