-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate keys do not error #59396
Comments
Related: #43186 |
Presumably this isn't a bug but a limitation, since TS doesn't track identity of variables here. If the type of |
ok,After mentioning it, I found that this is indeed the case, but there is no recommended writing that can avoid this problem. Because in this code, found a problem, only to find the key duplicate, was overwritten. It's hard. |
@jcalz Presumably it could check if the identifier is used twice in the object initialization. But I don't know how realistic this issue is and how expensive this check would be. |
We could error on the same identifier; the odds a prior property initializer really mutate it seem low enough. But this also seems like a fairly rare mistake to make and would incur a relatively high cost to keep track of all the identifiers and check for uniqueness. We'd need to see more than a handful of instances of this particular problem happening and see the larger context of the code (maybe there's a better check, hard to say). |
eslint Performance will be better? |
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
🙁 Actual behavior
no error
🙂 Expected behavior
error
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: