Clone properties prior to constructing accessors so they don't get shared and stomped on.

This commit is contained in:
Daniel Rosenwasser
2022-08-26 07:35:48 +00:00
parent 20432a64e3
commit b1358db5d1

View File

@@ -124,21 +124,21 @@ 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 : createStubbedMethodBody(quotePreference)));
}
else {
Debug.assertNode(accessor, isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
const parameter = getSetAccessorValueParameter(accessor);
const parameterName = parameter && isIdentifier(parameter.name) ? idText(parameter.name) : undefined;
addClassElement(factory.createSetAccessorDeclaration(
modifiers,
name,
createDummyParameters(1, [parameterName], [typeNode], 1, /*inJs*/ false),
ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
getSynthesizedDeepClones(modifiers),
getSynthesizedDeepClone(name),
createDummyParameters(1, [parameterName], [getSynthesizedDeepClone(typeNode)], 1, /*inJs*/ false),
ambient ? undefined : createStubbedMethodBody(quotePreference)));
}
}
break;