Skip to content

codeFixInferFromUsage should infer a null type when --strictNullChecks is enabled #24168

Closed
@ghost

Description

TypeScript Version: 2.9.0-dev.20180516

Search Terms:

Code

let x = null;
function h() {
    if (!x) x = 2;
}

Expected behavior:

let x: number | null = null;

Actual behavior:

let x: number = null;

which is a compile error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions