-
Notifications
You must be signed in to change notification settings - Fork 12.8k
A type can be named undefined #57573
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
Comments
Amusingly, this matches runtime behavior: |
@fatcerberus It does partially match that. Except in ES5 if you defined We could allow it. But it'd rather ban it π |
I can't imagine anyone doing this on purpose except to be evil... banning seems like the right call |
On second look, what is the problem here per se? Whenever you write If you do this outside of a namespace, it will say no, but inside it's just a symbol that can only be accessed from the namespace, no other way, so this doesn't seem harmful, just... weird? |
Hm, no, it won't say no outside of a namespace. Just error when it's also a global. https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBDAnmYcCuA7AJsAZgSw2CzgF44AiCgbgFgAoIA |
But it feels very strange that you have a local type named Erroring on |
Ah, there's the error I was looking for. Thanks. |
export type undefined = "";
let m: undefined = "";
// error^ If it's not going to work, we shouldn't let you do it |
Related #43215 Did anyone check this time there are no other such identifiers? Is there anything like identifier contingency plan, such as refactoring the parser to support precisely defined thought-through identifier classes? I suspect this might either not be fixed, or will break again soon. |
Yes: #57575 (comment) |
|
π Search Terms
type named undefined
π Version & Regression Information
β― Playground Link
Playground Link
π» Code
π Actual behavior
Inside the namespace
undefined
is the globalundefined
type. We can access the type if we qualify it with the namespaceπ Expected behavior
undefined
should not be allowed as a type name. (null
is not)Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: