Skip to content

Incorrect quick fix for undeclared private field in javascript files #36068

@mjbvz

Description

@mjbvz

TypeScript Version: 3.8.0-dev.20200108

Search Terms:

Code

For a js file

//@ts-check

class Private {
    constructor(name) {
        this.#name = name;
    }
}

Trigger the initialize property name quick fix

Expected behavior:
Initializer added in class:

//@ts-check

class Private {
    #name;
    
    constructor(name) {
        this.#name = name;
    }
}

Actual behavior:
Initializer added in the ctor:

//@ts-check

class Private {
    constructor(name) {
        this.#name = name;
        this.#name = undefined;
    }
}

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

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