mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
create new lexical environment for the body of converted loop (#12831)
This commit is contained in:
@@ -2286,14 +2286,19 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
startLexicalEnvironment();
|
||||
let loopBody = visitNode(node.statement, visitor, isStatement);
|
||||
const lexicalEnvironment = endLexicalEnvironment();
|
||||
|
||||
const currentState = convertedLoopState;
|
||||
convertedLoopState = outerConvertedLoopState;
|
||||
|
||||
if (loopOutParameters.length) {
|
||||
if (loopOutParameters.length || lexicalEnvironment) {
|
||||
const statements = isBlock(loopBody) ? (<Block>loopBody).statements.slice() : [loopBody];
|
||||
copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements);
|
||||
if (loopOutParameters.length) {
|
||||
copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements);
|
||||
}
|
||||
addRange(statements, lexicalEnvironment)
|
||||
loopBody = createBlock(statements, /*location*/ undefined, /*multiline*/ true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user