Skip to content

Commit 7077dd9

Browse files
committed
getLeftmostExpression: handle AsExpression and NonNullExpression
Fixes: #25223
1 parent a1746d4 commit 7077dd9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/compiler/factory.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4340,7 +4340,7 @@ namespace ts {
43404340
}
43414341
}
43424342

4343-
function getLeftmostExpression(node: Expression, stopAtCallExpressions: boolean) {
4343+
function getLeftmostExpression(node: Expression, stopAtCallExpressions: boolean | undefined) {
43444344
while (true) {
43454345
switch (node.kind) {
43464346
case SyntaxKind.PostfixUnaryExpression:
@@ -4354,19 +4354,17 @@ namespace ts {
43544354
case SyntaxKind.ConditionalExpression:
43554355
node = (<ConditionalExpression>node).condition;
43564356
continue;
4357-
43584357
case SyntaxKind.CallExpression:
43594358
if (stopAtCallExpressions) {
43604359
return node;
43614360
}
43624361
// falls through
4362+
case SyntaxKind.AsExpression:
43634363
case SyntaxKind.ElementAccessExpression:
43644364
case SyntaxKind.PropertyAccessExpression:
4365-
node = (<CallExpression | PropertyAccessExpression | ElementAccessExpression>node).expression;
4366-
continue;
4367-
4365+
case SyntaxKind.NonNullExpression:
43684366
case SyntaxKind.PartiallyEmittedExpression:
4369-
node = (<PartiallyEmittedExpression>node).expression;
4367+
node = (<CallExpression | PropertyAccessExpression | ElementAccessExpression | AsExpression | NonNullExpression | PartiallyEmittedExpression>node).expression;
43704368
continue;
43714369
}
43724370

0 commit comments

Comments
 (0)