@@ -20714,8 +20714,10 @@ namespace ts {
20714
20714
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
20715
20715
}
20716
20716
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
+ ));
20719
20721
}
20720
20722
20721
20723
function getPartOfForStatementContainingNode(node: Node, container: ForStatement) {
@@ -20740,11 +20742,11 @@ namespace ts {
20740
20742
// if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement)
20741
20743
20742
20744
const container = getEnclosingBlockScopeContainer(symbol.valueDeclaration);
20743
- const usedInFunction = isInsideFunction (node.parent , container);
20745
+ const isCaptured = isInsideFunctionOrInstancePropertyInitializer (node, container);
20744
20746
20745
20747
const enclosingIterationStatement = getEnclosingIterationStatement(container);
20746
20748
if (enclosingIterationStatement) {
20747
- if (usedInFunction ) {
20749
+ if (isCaptured ) {
20748
20750
// mark iteration statement as containing block-scoped binding captured in some function
20749
20751
let capturesBlockScopeBindingInLoopBody = true;
20750
20752
if (isForStatement(container)) {
@@ -20782,7 +20784,7 @@ namespace ts {
20782
20784
getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.BlockScopedBindingInLoop;
20783
20785
}
20784
20786
20785
- if (usedInFunction ) {
20787
+ if (isCaptured ) {
20786
20788
getNodeLinks(symbol.valueDeclaration).flags |= NodeCheckFlags.CapturedBlockScopedBinding;
20787
20789
}
20788
20790
}
0 commit comments