Skip to content

Infer string literals types in const declarations #5796

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
wants to merge 10 commits into from

Conversation

DanielRosenwasser
Copy link
Member

This PR experimentally adds functionality so that string literals are given string literal types in const declarations. It is the first step towards exploring "mutability widening" as brought up in the design meeting.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 2, 2015

this still does not answer cases like:

const blue = "blue";
const red= "red";

let color = blue;
if (Math.random()) {
    color = red; /// Error !
}

in #5740 we talked about handling let and const differently, and allowing for different widening rules.

@DanielRosenwasser
Copy link
Member Author

I don't think this is the right thing to do for now.

@mhegazy mhegazy deleted the inferStringLiteralsForConst branch November 2, 2017 21:02
@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.

3 participants