Skip to content

Need a flag to check if checking an expression for null or undefined has not that types #14839

@cevek

Description

@cevek

Often we have to check variables for empty values.
If variables has undefined or null types we check for that types.
But if we want to refactor our code, and replace nullable variables to always with value, we init its with empty values like false, 0, -1, ""
But checks that variables for null or undefined in other parts of program are still there, and make a lot of bugs

let a: string | undefined;
if (a !== undefined) {
   foo(a);
}

// and if we refactor

let a = '';
// In this check we potentially has a bug, cause undefined is not possible here, 
if (a !== undefined) {
   foo(a);
}

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