@@ -22254,8 +22254,10 @@ namespace ts {
2225422254 return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
2225522255 }
2225622256
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+ ));
2225922261 }
2226022262
2226122263 function getPartOfForStatementContainingNode(node: Node, container: ForStatement) {
@@ -22280,11 +22282,11 @@ namespace ts {
2228022282 // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement)
2228122283
2228222284 const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration);
22283- const usedInFunction = isInsideFunction (node.parent , container);
22285+ const isCaptured = isInsideFunctionOrInstancePropertyInitializer (node, container);
2228422286
2228522287 const enclosingIterationStatement = getEnclosingIterationStatement(container);
2228622288 if (enclosingIterationStatement) {
22287- if (usedInFunction ) {
22289+ if (isCaptured ) {
2228822290 // mark iteration statement as containing block-scoped binding captured in some function
2228922291 let capturesBlockScopeBindingInLoopBody = true;
2229022292 if (isForStatement(container)) {
@@ -22322,7 +22324,7 @@ namespace ts {
2232222324 getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop;
2232322325 }
2232422326
22325- if (usedInFunction ) {
22327+ if (isCaptured ) {
2232622328 getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.CapturedBlockScopedBinding;
2232722329 }
2232822330 }
0 commit comments