Skip to content

Generalize never type handling for control flow analysis based type guard #12825

Open
@vilicvane

Description

@vilicvane

I guess there would be some duplicates, but I cannot find it.

TypeScript Version: 2.1.14

Code

function throwError(): never {
    throw new Error();
}

let foo: string | undefined;

if (!foo) {
    throwError();
}

foo; // Expected to be `string` instead of `string | undefined`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions