Skip to content

Commit 42600fa

Browse files
committed
ES2015 transforms accessors with captured this
Previously, it did not, meaning that the emit for lexically captured `this` was incorrect.
1 parent a0abadb commit 42600fa

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/compiler/transformers/es2015.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3180,7 +3180,20 @@ namespace ts {
31803180
const savedConvertedLoopState = convertedLoopState;
31813181
convertedLoopState = undefined;
31823182
const ancestorFacts = enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes);
3183-
const updated = visitEachChild(node, visitor, context);
3183+
let updated: AccessorDeclaration;
3184+
if (node.transformFlags & TransformFlags.ContainsCapturedLexicalThis) {
3185+
const parameters = visitParameterList(node.parameters, visitor, context);
3186+
const body = transformFunctionBody(node);
3187+
if (node.kind === SyntaxKind.GetAccessor) {
3188+
updated = updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
3189+
}
3190+
else {
3191+
updated = updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
3192+
}
3193+
}
3194+
else {
3195+
updated = visitEachChild(node, visitor, context);
3196+
}
31843197
exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None);
31853198
convertedLoopState = savedConvertedLoopState;
31863199
return updated;

0 commit comments

Comments
 (0)