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

Documentation: literal "types" #18102

Closed
bodawei opened this issue Aug 29, 2017 · 3 comments
Closed

Documentation: literal "types" #18102

bodawei opened this issue Aug 29, 2017 · 3 comments
Labels
Spec Issues related to the TypeScript language specification

Comments

@bodawei
Copy link

bodawei commented Aug 29, 2017

Code

Try the following out at https://www.typescriptlang.org/play/index.html (sadly, this is too long to include a sharable link)

let num1: 1;
let num2: 2;
let num3: typeof num2;
num3 = num2;
num3 = num1;

Expected behavior:
This works exactly as expected, such that there's an error on the second assignment to num3.

I don't easily see something in your doc that mentions this is possible. It is probably implicit in various places, as it is particularly useful with some unions. Seems like calling this out explicitly would be valuable?

@mhegazy mhegazy added the Spec Issues related to the TypeScript language specification label Aug 29, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Aug 29, 2017

The spec needs to be updated for these.

Some relevant readings meanwhile, literal types are widened to their base type in mutable locations (see #10676), and explicit literal type annotations are not widened (see #11126)

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Nov 15, 2017

Another relevant change is that our section on specialized signatures needs to be simplified. As far as I remember, specialized signatures are only re-sorted now.

See #6278

@RyanCavanaugh
Copy link
Member

The spec is now an "archived" artifact and we won't be tracking defects against it anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Spec Issues related to the TypeScript language specification
Projects
None yet
Development

No branches or pull requests

4 participants