Skip to content

Commit e897eb1

Browse files
authored
fix(37817): omit comments in name accessor (#37822)
1 parent e4babd4 commit e897eb1

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/services/refactors/generateGetAccessorAndSetAccessor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor {
4646
const { isStatic, isReadonly, fieldName, accessorName, originalName, type, container, declaration, renameAccessor } = fieldInfo;
4747

4848
suppressLeadingAndTrailingTrivia(fieldName);
49+
suppressLeadingAndTrailingTrivia(accessorName);
4950
suppressLeadingAndTrailingTrivia(declaration);
5051
suppressLeadingAndTrailingTrivia(container);
5152

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////class Foo {
4+
//// /**
5+
//// * Property description
6+
//// */
7+
//// /*a*/_prop!: string; // comment/*b*/
8+
////}
9+
10+
goTo.select("a", "b");
11+
edit.applyRefactor({
12+
refactorName: "Generate 'get' and 'set' accessors",
13+
actionName: "Generate 'get' and 'set' accessors",
14+
actionDescription: "Generate 'get' and 'set' accessors",
15+
newContent:
16+
`class Foo {
17+
/**
18+
* Property description
19+
*/
20+
private _prop!: string; // comment
21+
public get /*RENAME*/prop(): string {
22+
return this._prop;
23+
}
24+
public set prop(value: string) {
25+
this._prop = value;
26+
}
27+
}`
28+
});

0 commit comments

Comments
 (0)