ES2015 transforms accessors with captured this

Previously, it did not, meaning that the emit for lexically captured
`this` was incorrect.
This commit is contained in:
Nathan Shively-Sanders 2017-04-24 14:46:58 -07:00 committed by Mohamed Hegazy
parent 1d209d50e3
commit 69623146bd

View File

@ -3180,7 +3180,20 @@ namespace ts {
const savedConvertedLoopState = convertedLoopState;
convertedLoopState = undefined;
const ancestorFacts = enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes);
const updated = visitEachChild(node, visitor, context);
let updated: AccessorDeclaration;
if (node.transformFlags & TransformFlags.ContainsCapturedLexicalThis) {
const parameters = visitParameterList(node.parameters, visitor, context);
const body = transformFunctionBody(node);
if (node.kind === SyntaxKind.GetAccessor) {
updated = updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
}
else {
updated = updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body);
}
}
else {
updated = visitEachChild(node, visitor, context);
}
exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None);
convertedLoopState = savedConvertedLoopState;
return updated;