Skip to content

Global variables in local functions are not control flow analysed #8472

Closed
@tinganho

Description

@tinganho

str has been asserted it cannot be undefined on all call sites of test() below:

let str: string | undefined;
if (str) {
    test();
}

function test() {
    str.charAt(1); // error can be undefined
}

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