Skip to content

Incorrect error generated when comparing enum values. #10989

Closed
@dbaeumer

Description

@dbaeumer

TypeScript Version: 2.0.2
Code

enum Direction {
    LEFT,
    RIGHT
}

function bug(direction?: Direction): number {
    if (!direction) {
        return 10;
    } else {
        return (direction === Direction.LEFT) ? 10 : 0;
    }
}

You get a compile error saying the Direction can't be used in ===. This is IMO incorrect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions