Skip to content

Mutually exclusive guard constraints and 'never' #9869

Closed
@zhuravlikjb

Description

@zhuravlikjb

Applying two mutually exclusive guard constraints doesn't lead to 'never' type in the following case:

function ololo() {
    let stringOrNumber: string | number = 3 > 5 ? "a" : 7;

    if (typeof stringOrNumber === "number") {
        if (typeof stringOrNumber !== "number") {
            stringOrNumber; // shouldn't this be 'never'?
        }
    } 

Seems that it should.

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