Skip to content

Make undefined valid as a type name#5387

Closed
weswigham wants to merge 1 commit into
microsoft:masterfrom
weswigham:3087-undefined-typename
Closed

Make undefined valid as a type name#5387
weswigham wants to merge 1 commit into
microsoft:masterfrom
weswigham:3087-undefined-typename

Conversation

@weswigham

Copy link
Copy Markdown
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

vladima commented Oct 24, 2015

Copy link
Copy Markdown
Contributor

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

@mhegazy

mhegazy commented Oct 26, 2015

Copy link
Copy Markdown
Contributor

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

Comment thread src/compiler/checker.ts

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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