Merge pull request #11130 from Microsoft/fix11031

Fix downlevel async hoisting
This commit is contained in:
Ron Buckton 2016-09-25 10:56:25 -07:00 committed by GitHub
commit 992b385dfe
2 changed files with 9 additions and 4 deletions

View File

@ -573,11 +573,11 @@ namespace ts {
operationLocations = undefined;
state = createTempVariable(/*recordTempVariable*/ undefined);
const statementOffset = addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor);
// Build the generator
startLexicalEnvironment();
const statementOffset = addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor);
transformAndEmitStatements(body.statements, statementOffset);
const buildResult = build();
@ -615,6 +615,11 @@ namespace ts {
return undefined;
}
else {
// Do not hoist custom prologues.
if (node.emitFlags & NodeEmitFlags.CustomPrologue) {
return node;
}
for (const variable of node.declarationList.declarations) {
hoistVariableDeclaration(<Identifier>variable.name);
}

View File

@ -9,7 +9,7 @@ var bar = async (): Promise<void> => {
//// [asyncArrowFunction7_es5.js]
var _this = this;
var bar = function () { return __awaiter(_this, void 0, void 0, function () {
_this = this;
var _this = this;
var foo;
return __generator(this, function (_a) {
foo = function (a) {
@ -22,4 +22,4 @@ var bar = function () { return __awaiter(_this, void 0, void 0, function () {
};
return [2 /*return*/];
});
}); var _this; };
}); };