Fixed issue where last function context & parent node wasn't being preserved.

This came up when a `super()` call was nested in another constructor body.
Current logic in the transform says that if the last containing non-arrow
function body is non-static, and the current parent isn't a call expression,
the call target of a `super` call will become `_super.prototype` instead
of `super`.

If the state is not saved, the containing arrow function and parent
are not saved, and the information for this check won't be accurate.
This commit is contained in:
Daniel Rosenwasser 2016-09-03 00:16:43 -07:00
parent d6e548b02e
commit 11bc6c470f

View File

@ -1143,9 +1143,10 @@ namespace ts {
firstStatement = ctor.body.statements[firstNonPrologue];
if (firstStatement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((firstStatement as ExpressionStatement).expression)) {
const superCall = (firstStatement as ExpressionStatement).expression as CallExpression;
initializer = setOriginalNode(
visitImmediateSuperCallInBody(((firstStatement as ExpressionStatement).expression as CallExpression)),
(firstStatement as ExpressionStatement).expression
saveStateAndInvoke(superCall, visitImmediateSuperCallInBody),
superCall
);
}
}