Skip to content

Switch Case not working with String conditions  #10802

@06needhamt

Description

@06needhamt

TypeScript Version: 1.8.34

Code

// A *self-contained* demonstration of the problem follows...
let extension: String = "bin";
        switch (extension) {
            case "txt", "xml":
                return ResourceType.PlainText;
            case "bmp", "jpg", "jpeg", "png", "tiff", "psd", "tga", "gif":
                return ResourceType.Image;
            case "mp3", "wav", "ogg", "flac", "wma", "m4a":
                return ResourceType.Audio;
            case "bin", "dat":
                return ResourceType.Binary;
            case "ico":
                return ResourceType.Icon;
            case "rc", "resx":
                return ResourceType.ResourceScript;
            default:
                return ResourceType.Unknown;
}

Expected behavior:
The Switch case will return the correct value based on the condition ex when extension == "bin" ResourceType.Binary should be returned
Actual behavior:
The Default value is always returned

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions