Skip to content

Commit bb7818b

Browse files
committed
Consider property declarations to be control flow containers
1 parent 6dcd587 commit bb7818b

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/compiler/checker.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8091,13 +8091,22 @@ namespace ts {
80918091
return expression;
80928092
}
80938093

8094+
function getControlFlowContainer(node: Node): Node {
8095+
while (true) {
8096+
node = node.parent;
8097+
if (isFunctionLike(node) || node.kind === SyntaxKind.ModuleBlock || node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.PropertyDeclaration) {
8098+
return node;
8099+
}
8100+
}
8101+
}
8102+
80948103
function isDeclarationIncludedInFlow(reference: Node, declaration: Declaration, includeOuterFunctions: boolean) {
8095-
const declarationContainer = getContainingFunctionOrModule(declaration);
8096-
let container = getContainingFunctionOrModule(reference);
8104+
const declarationContainer = getControlFlowContainer(declaration);
8105+
let container = getControlFlowContainer(reference);
80978106
while (container !== declarationContainer &&
80988107
(container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.ArrowFunction) &&
80998108
(includeOuterFunctions || getImmediatelyInvokedFunctionExpression(<FunctionExpression>container))) {
8100-
container = getContainingFunctionOrModule(container);
8109+
container = getControlFlowContainer(container);
81018110
}
81028111
return container === declarationContainer;
81038112
}

src/compiler/utilities.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -880,15 +880,6 @@ namespace ts {
880880
}
881881
}
882882

883-
export function getContainingFunctionOrModule(node: Node): Node {
884-
while (true) {
885-
node = node.parent;
886-
if (isFunctionLike(node) || node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.SourceFile) {
887-
return node;
888-
}
889-
}
890-
}
891-
892883
export function getContainingClass(node: Node): ClassLikeDeclaration {
893884
while (true) {
894885
node = node.parent;

0 commit comments

Comments
 (0)