Skip to content
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

Proposal: 'always' type #13804

Closed
pelotom opened this issue Feb 1, 2017 · 7 comments
Closed

Proposal: 'always' type #13804

pelotom opened this issue Feb 1, 2017 · 7 comments
Labels
Duplicate An existing issue was already created

Comments

@pelotom
Copy link

pelotom commented Feb 1, 2017

We have a never type representing the bottom of the type lattice... what about having a built-in corresponding "top" type? Essentially:

type always = {} | void | null

A variable of type always can be assigned any value, but nothing is known about it aside from the fact that it exists. any doesn't fit the bill, because we can assign an any to any other type and access arbitrary properties on it (it behaves like both never and always depending on the context).

@RyanCavanaugh
Copy link
Member

The suggestion is simply to add that line to lib.d.ts?

@pelotom
Copy link
Author

pelotom commented Feb 1, 2017

It would be ideal if it was built-in rather than a type alias, so that it didn't get expanded to {} | void | null everywhere, but failing that a type alias in the lib would be fine.

@dead-claudia
Copy link

This sounds like a dupe of #10715, just with a different name. unknown there and always here are both top types.

@RyanCavanaugh
Copy link
Member

Some elaboration of the desired use of this type would be helpful. What's it for? Why would I use it? What would the documentation say about it?

@pelotom
Copy link
Author

pelotom commented Mar 6, 2017

@RyanCavanaugh #10715 has a good detailed description of why this is desirable.

@RyanCavanaugh
Copy link
Member

Is this a duplicate then?

@pelotom
Copy link
Author

pelotom commented Mar 6, 2017

Yes, modulo a suggestion of what to call this type.

@pelotom pelotom closed this as completed Mar 6, 2017
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 6, 2017
@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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants