mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Move 'use strict' directive out of generator for async function.
This commit is contained in:
@@ -572,10 +572,12 @@ namespace ts {
|
||||
operationLocations = undefined;
|
||||
state = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
|
||||
const statementOffset = addPrologueDirectives(statements, body.statements);
|
||||
|
||||
// Build the generator
|
||||
startLexicalEnvironment();
|
||||
|
||||
transformAndEmitStatements(body.statements);
|
||||
transformAndEmitStatements(body.statements, statementOffset);
|
||||
|
||||
const buildResult = build();
|
||||
addNodes(statements, endLexicalEnvironment());
|
||||
@@ -1117,9 +1119,10 @@ namespace ts {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function transformAndEmitStatements(statements: Statement[]) {
|
||||
for (const statement of statements) {
|
||||
transformAndEmitStatement(statement);
|
||||
function transformAndEmitStatements(statements: Statement[], start = 0) {
|
||||
const numStatements = statements.length;
|
||||
for (let i = start; i < numStatements; i++) {
|
||||
transformAndEmitStatement(statements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2181,11 +2181,13 @@ namespace ts {
|
||||
return transformFunctionBodyWorker(node.body);
|
||||
}
|
||||
|
||||
function transformFunctionBodyWorker(body: Block) {
|
||||
function transformFunctionBodyWorker(body: Block, start = 0) {
|
||||
const savedCurrentScope = currentScope;
|
||||
currentScope = body;
|
||||
startLexicalEnvironment();
|
||||
const visited = visitEachChild(body, visitor, context);
|
||||
|
||||
const statements = visitNodes(body.statements, visitor, isStatement, start);
|
||||
const visited = updateBlock(body, statements);
|
||||
const declarations = endLexicalEnvironment();
|
||||
currentScope = savedCurrentScope;
|
||||
return mergeFunctionBodyLexicalEnvironment(visited, declarations);
|
||||
@@ -2233,14 +2235,14 @@ namespace ts {
|
||||
|
||||
if (!isArrowFunction) {
|
||||
const statements: Statement[] = [];
|
||||
|
||||
const statementOffset = addPrologueDirectives(statements, (<Block>node.body).statements);
|
||||
statements.push(
|
||||
createReturn(
|
||||
createAwaiterHelper(
|
||||
currentSourceFileExternalHelpersModuleName,
|
||||
hasLexicalArguments,
|
||||
promiseConstructor,
|
||||
transformFunctionBodyWorker(<Block>node.body)
|
||||
transformFunctionBodyWorker(<Block>node.body, statementOffset)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user