@@ -20714,8 +20714,10 @@ namespace ts {
2071420714 return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
2071520715 }
2071620716
20717- function isInsideFunction(node: Node, threshold: Node): boolean {
20718- return !!findAncestor(node, n => n === threshold ? "quit" : isFunctionLike(n));
20717+ function isInsideFunctionOrInstancePropertyInitializer(node: Node, threshold: Node): boolean {
20718+ return !!findAncestor(node, n => n === threshold ? "quit" : isFunctionLike(n) || (
20719+ n.parent && isPropertyDeclaration(n.parent) && !hasStaticModifier(n.parent) && n.parent.initializer === n
20720+ ));
2071920721 }
2072020722
2072120723 function getPartOfForStatementContainingNode(node: Node, container: ForStatement) {
@@ -20740,11 +20742,11 @@ namespace ts {
2074020742 // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement)
2074120743
2074220744 const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration);
20743- const usedInFunction = isInsideFunction (node.parent , container);
20745+ const isCaptured = isInsideFunctionOrInstancePropertyInitializer (node, container);
2074420746
2074520747 const enclosingIterationStatement = getEnclosingIterationStatement(container);
2074620748 if (enclosingIterationStatement) {
20747- if (usedInFunction ) {
20749+ if (isCaptured ) {
2074820750 // mark iteration statement as containing block-scoped binding captured in some function
2074920751 let capturesBlockScopeBindingInLoopBody = true;
2075020752 if (isForStatement(container)) {
@@ -20782,7 +20784,7 @@ namespace ts {
2078220784 getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop;
2078320785 }
2078420786
20785- if (usedInFunction ) {
20787+ if (isCaptured ) {
2078620788 getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.CapturedBlockScopedBinding;
2078720789 }
2078820790 }
0 commit comments