Skip to content

switch case unreachable code checking when use string literals #7745

Closed
@stepancar

Description

@stepancar

Hello! See example

type lang = "en" | "ru";
function getDict(lng: lang): any {
    switch (lng) {
        case 'ru':
            return ru;
        case 'stringNotInLangType':
            return en;
    }
}

compiler should throw error, cause

 case 'stringNotInLangType':
            return en;

is unreachable

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions