Skip to content

Make undefined valid as a type name #5387

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

Closed

Conversation

weswigham
Copy link
Member

Fixes #3087.

If the user introduces a global named undefined we no longer attempt to add the undefined builtin to the global table - the user's type overrides it.

@vladima
Copy link
Contributor

vladima commented Oct 24, 2015

As I understand user defined undefined has only type meaning. Does this mean that I can no longer use undefined as value?

@mhegazy
Copy link
Contributor

mhegazy commented Oct 26, 2015

i wonder if we should disallow this to enable a built-in undefined type in the future.

@@ -14885,7 +14885,9 @@ namespace ts {
getSymbolLinks(undefinedSymbol).type = undefinedType;
getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments");
getSymbolLinks(unknownSymbol).type = unknownType;
globals[undefinedSymbol.name] = undefinedSymbol;
if (!globals[undefinedSymbol.name]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasProperty

@DanielRosenwasser
Copy link
Member

I agree with @mhegazy and I don't think this is the appropriate fix. The idea right now is that the compiler anticipates using the undefined type whenever it encounters undefined. Allowing any other type gives a drastically different meaning to the language.

We should be disallowing undefined as a type name, the same way you can't have a type alias named number right now.

@weswigham
Copy link
Member Author

Alright.

@weswigham weswigham closed this Oct 26, 2015
@weswigham weswigham deleted the 3087-undefined-typename branch August 17, 2017 23:03
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants