TypeScript/tests/cases/fourslash/refactorConvertToGetAccessAndSetAccess10.ts
Wenlu Wang 9c0671d661 add refactor of convert private field to getter and setter (#22143)
* add refactor of convert private field to getter and setter

* fix refactor

* stash

* refactor accessor generate

* revert merge union type

* refeactor and accept baseline

* add support of PropertyAssignment and StringLiteral

* add support for js file

* allow static modifier in js file
2018-04-10 11:51:41 -07:00

22 lines
525 B
TypeScript

/// <reference path='fourslash.ts' />
//// class A {
//// /*a*/public a?: string = "foo";/*b*/
//// }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Generate 'get' and 'set' accessors",
actionName: "Generate 'get' and 'set' accessors",
actionDescription: "Generate 'get' and 'set' accessors",
newContent: `class A {
private /*RENAME*/_a?: string = "foo";
public get a(): string {
return this._a;
}
public set a(value: string) {
this._a = value;
}
}`,
});