Skip to content

switch case unreachable code checking when use string literals #7745

Closed

Description

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

Activity

  1. mhegazy commented on Mar 31, 2016

    @mhegazy
    Contributor

    duplicate of #6149

  2. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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