@@ -22254,8 +22254,10 @@ namespace ts {
22254
22254
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
22255
22255
}
22256
22256
22257
- function isInsideFunction(node: Node, threshold: Node): boolean {
22258
- return !!findAncestor(node, n => n === threshold ? "quit" : isFunctionLike(n));
22257
+ function isInsideFunctionOrInstancePropertyInitializer(node: Node, threshold: Node): boolean {
22258
+ return !!findAncestor(node, n => n === threshold ? "quit" : isFunctionLike(n) || (
22259
+ n.parent && isPropertyDeclaration(n.parent) && !hasStaticModifier(n.parent) && n.parent.initializer === n
22260
+ ));
22259
22261
}
22260
22262
22261
22263
function getPartOfForStatementContainingNode(node: Node, container: ForStatement) {
@@ -22280,11 +22282,11 @@ namespace ts {
22280
22282
// if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement)
22281
22283
22282
22284
const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration);
22283
- const usedInFunction = isInsideFunction (node.parent , container);
22285
+ const isCaptured = isInsideFunctionOrInstancePropertyInitializer (node, container);
22284
22286
22285
22287
const enclosingIterationStatement = getEnclosingIterationStatement(container);
22286
22288
if (enclosingIterationStatement) {
22287
- if (usedInFunction ) {
22289
+ if (isCaptured ) {
22288
22290
// mark iteration statement as containing block-scoped binding captured in some function
22289
22291
let capturesBlockScopeBindingInLoopBody = true;
22290
22292
if (isForStatement(container)) {
@@ -22322,7 +22324,7 @@ namespace ts {
22322
22324
getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop;
22323
22325
}
22324
22326
22325
- if (usedInFunction ) {
22327
+ if (isCaptured ) {
22326
22328
getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.CapturedBlockScopedBinding;
22327
22329
}
22328
22330
}
0 commit comments