Skip to content

VSCode - generate accessors fixup on readonly field removes modifier #33836

@slaneyrw

Description

@slaneyrw

TypeScript Version: 3.6.2

Search Terms: VSCode generate accessors

Logged issue with VSCode repo, but they asked my to create an issue "upstream"
microsoft/vscode#81135

Steps to Reproduce:

  1. Create private field with readonly modifier
  2. Highlight line and generate accessors
  3. get property created without set property ( correct ), but readonly modifier removed from field

Code

// before
class MyClass {

    private readonly _myField: number;

}


// after
class MyClass {

    private _myField: number;

    public get myField() {
        return this._myField;
    }
}

Expected behavior:

readonly modifier should remain on private field.
GET accessor created
SET accessor NOT created

Actual behavior:

readonly modifier is removed.
GET accessor created
SET accessor NOT created

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Refactoringse.g. extract to constant or function, rename symbol

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions