Skip to content

Invalid quickfix output for code fix all for infer type from usage #24148

Closed
@mhegazy

Description

@mhegazy

TypeScript Version: 2.9.0-dev.201xxxxx

Search Terms:

Code

let x = null;

function foo () {
    if (!x) {  // CodeFix all
        x = 22;
    }
}

function bar() {
    console.log(x);
}

Expected behavior:

let x: number | null = null;

function foo () {
    if (!x) {
        x = 22;
    }
}


function bar() {
    console.log(x);
}

Actual behavior:

let x: number: number: number = null;

function foo () {
    if (!x) {
        x = 22;
    }
}

function bar() {
    console.log(x);
}

Playground Link:

Related Issues:

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