Skip to content

Generate getter/setter for property already starting with _ #24155

Closed
@mjbvz

Description

@mjbvz

TypeScript Version: 2.9.0-dev.20180515

Search Terms:

  • refactor / refactoring
  • generate get / getters, set / setters

Code

class Foo {
    private _prop: number
}

Run the generate get and set accessors refactoring on _prop

Expected behavior:
I think we should remove the _ from the exposed property names in this case:

class Foo {
    private _prop: number;
    public get prop(): number {
        return this._prop;
    }
    public set prop(value: number) {
        this._prop = value;
    }
}

Actual behavior:
We tack on another _ to the field and use _prop as the public names

class Foo {
    private __prop: number;
    public get _prop(): number {
        return this.__prop;
    }
    public set _prop(value: number) {
        this.__prop = value;
    }
}

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