@@ -23485,8 +23485,10 @@ namespace ts {
23485
23485
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
23486
23486
}
23487
23487
23488
- function isInsideFunction(node: Node, threshold: Node): boolean {
23489
- return !!findAncestor(node, n => n === threshold ? "quit" : isFunctionLike(n));
23488
+ function isInsideFunctionOrInstancePropertyInitializer(node: Node, threshold: Node): boolean {
23489
+ return !!findAncestor(node, n => n === threshold ? "quit" : isFunctionLike(n) || (
23490
+ n.parent && isPropertyDeclaration(n.parent) && !hasStaticModifier(n.parent) && n.parent.initializer === n
23491
+ ));
23490
23492
}
23491
23493
23492
23494
function getPartOfForStatementContainingNode(node: Node, container: ForStatement) {
@@ -23511,11 +23513,11 @@ namespace ts {
23511
23513
// if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement)
23512
23514
23513
23515
const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration);
23514
- const usedInFunction = isInsideFunction (node.parent , container);
23516
+ const isCaptured = isInsideFunctionOrInstancePropertyInitializer (node, container);
23515
23517
23516
23518
const enclosingIterationStatement = getEnclosingIterationStatement(container);
23517
23519
if (enclosingIterationStatement) {
23518
- if (usedInFunction ) {
23520
+ if (isCaptured ) {
23519
23521
// mark iteration statement as containing block-scoped binding captured in some function
23520
23522
let capturesBlockScopeBindingInLoopBody = true;
23521
23523
if (isForStatement(container)) {
@@ -23553,7 +23555,7 @@ namespace ts {
23553
23555
getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop;
23554
23556
}
23555
23557
23556
- if (usedInFunction ) {
23558
+ if (isCaptured ) {
23557
23559
getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.CapturedBlockScopedBinding;
23558
23560
}
23559
23561
}
0 commit comments