Skip to content

Commit

Permalink
fix(50415): clone props for get/set accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Aug 26, 2022
1 parent c4eb37c commit bd27b3b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/services/codefixes/helpers.ts
Expand Up @@ -124,11 +124,11 @@ namespace ts.codefix {
for (const accessor of orderedAccessors) {
if (isGetAccessorDeclaration(accessor)) {
addClassElement(factory.createGetAccessorDeclaration(
modifiers,
name,
getSynthesizedDeepClones(modifiers),
getSynthesizedDeepClone(name),
emptyArray,
typeNode,
ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
getSynthesizedDeepClone(typeNode),
ambient ? undefined : getSynthesizedDeepClone(body) || createStubbedMethodBody(quotePreference)));
}
else {
Debug.assertNode(accessor, isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
Expand Down
27 changes: 27 additions & 0 deletions tests/cases/fourslash/completionsOverridingMethod15.ts
@@ -0,0 +1,27 @@
/// <reference path="fourslash.ts" />

// @newline: LF
////declare class B {
//// get foo(): any;
//// set foo(value: any);
////}
////class A extends B {
//// /**/
////}

verify.completions({
marker: "",
preferences: {
includeCompletionsWithInsertText: true,
includeCompletionsWithSnippetText: false,
includeCompletionsWithClassMemberSnippets: true,
},
includes: [
{
name: "foo",
sortText: completion.SortText.ClassMemberSnippets,
insertText: "get foo(): any {\n}\nset foo(value: any) {\n}",
}
],
isNewIdentifierLocation: true
})

0 comments on commit bd27b3b

Please sign in to comment.