Skip to content

Commit b3be79a

Browse files
committed
Skip parentheses
1 parent 1d34778 commit b3be79a

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34547,9 +34547,7 @@ namespace ts {
3454734547
: isBinaryExpression(location) && isIdentifier(location.right) ? location.right
3454834548
: undefined;
3454934549
const isPropertyExpressionCast = isPropertyAccessExpression(location)
34550-
&& isParenthesizedExpression(location.expression)
34551-
&& isAssertionExpression(location.expression.expression);
34552-
34550+
&& isAssertionExpression(skipParentheses(location.expression));
3455334551
if (!testedNode || isPropertyExpressionCast) {
3455434552
return;
3455534553
}

tests/baselines/reference/truthinessCallExpressionCoercion3.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ function f(result: unknown) {
99
return result
1010
}
1111
}
12+
function g(result: unknown) {
13+
if (((result as I)).always) {
14+
return result
15+
}
16+
}
1217

1318

1419
//// [truthinessCallExpressionCoercion3.js]
@@ -17,3 +22,8 @@ function f(result) {
1722
return result;
1823
}
1924
}
25+
function g(result) {
26+
if (result.always) {
27+
return result;
28+
}
29+
}

tests/baselines/reference/truthinessCallExpressionCoercion3.symbols

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,18 @@ function f(result: unknown) {
2121
>result : Symbol(result, Decl(truthinessCallExpressionCoercion3.ts, 5, 11))
2222
}
2323
}
24+
function g(result: unknown) {
25+
>g : Symbol(g, Decl(truthinessCallExpressionCoercion3.ts, 9, 1))
26+
>result : Symbol(result, Decl(truthinessCallExpressionCoercion3.ts, 10, 11))
27+
28+
if (((result as I)).always) {
29+
>((result as I)).always : Symbol(I.always, Decl(truthinessCallExpressionCoercion3.ts, 1, 13))
30+
>result : Symbol(result, Decl(truthinessCallExpressionCoercion3.ts, 10, 11))
31+
>I : Symbol(I, Decl(truthinessCallExpressionCoercion3.ts, 0, 0))
32+
>always : Symbol(I.always, Decl(truthinessCallExpressionCoercion3.ts, 1, 13))
33+
34+
return result
35+
>result : Symbol(result, Decl(truthinessCallExpressionCoercion3.ts, 10, 11))
36+
}
37+
}
2438

tests/baselines/reference/truthinessCallExpressionCoercion3.types

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,20 @@ function f(result: unknown) {
2020
>result : unknown
2121
}
2222
}
23+
function g(result: unknown) {
24+
>g : (result: unknown) => unknown
25+
>result : unknown
26+
27+
if (((result as I)).always) {
28+
>((result as I)).always : () => void
29+
>((result as I)) : I
30+
>(result as I) : I
31+
>result as I : I
32+
>result : unknown
33+
>always : () => void
34+
35+
return result
36+
>result : unknown
37+
}
38+
}
2339

tests/cases/compiler/truthinessCallExpressionCoercion3.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ function f(result: unknown) {
1111
return result
1212
}
1313
}
14+
function g(result: unknown) {
15+
if (((result as I)).always) {
16+
return result
17+
}
18+
}

0 commit comments

Comments
 (0)