Skip to content

[Feature] Lift Assignment out of an if statement conitional #20743

@IamManchanda

Description

@IamManchanda

Inspiration: Kotlin

This code below

    if (age < 18) {
       message = "You are too young to vote"
    } else if (age === 100) {
        message = "Congratulations"
    } else {
        message = "You can vote"
    }

can be converted like this for productivity and brevity

    message = if (age < 18) {
        "You are too young to vote"
    } else if (age == 100) {
        "Congratulations"
    } else {
        "You can vote"
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Out of ScopeThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions