|
1 |
| -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(3,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
2 |
| -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(6,10): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
3 |
| -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(30,18): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
4 |
| -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(36,46): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
5 |
| -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(47,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
6 |
| -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(50,10): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
7 |
| -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(66,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
8 |
| -tests/cases/compiler/truthinessCallExpressionCoercion2.ts(69,14): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
| 1 | +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(11,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
| 2 | +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(14,10): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
| 3 | +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(41,18): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
| 4 | +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(47,46): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
| 5 | +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(58,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
| 6 | +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(61,10): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
| 7 | +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(81,5): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
| 8 | +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(91,9): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
| 9 | +tests/cases/compiler/truthinessCallExpressionCoercion2.ts(94,14): error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
9 | 10 |
|
10 | 11 |
|
11 |
| -==== tests/cases/compiler/truthinessCallExpressionCoercion2.ts (8 errors) ==== |
| 12 | +==== tests/cases/compiler/truthinessCallExpressionCoercion2.ts (9 errors) ==== |
| 13 | + declare class A { |
| 14 | + static from(): string; |
| 15 | + } |
| 16 | + |
| 17 | + declare class B { |
| 18 | + static from(): string; |
| 19 | + } |
| 20 | + |
12 | 21 | function test(required1: () => boolean, required2: () => boolean, optional?: () => boolean) {
|
13 | 22 | // error
|
14 | 23 | required1 && console.log('required');
|
@@ -41,6 +50,9 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(69,14): error TS2774:
|
41 | 50 | // ok
|
42 | 51 | required1 && required2 && required1() && required2();
|
43 | 52 |
|
| 53 | + // ok |
| 54 | + [].forEach((f: () => void) => f && f.apply(parent, [])); |
| 55 | + |
44 | 56 | // error
|
45 | 57 | required1 && required2 && required1() && console.log('foo');
|
46 | 58 | ~~~~~~~~~
|
@@ -77,6 +89,22 @@ tests/cases/compiler/truthinessCallExpressionCoercion2.ts(69,14): error TS2774:
|
77 | 89 |
|
78 | 90 | // ok
|
79 | 91 | x.foo.bar && 1 && x.foo.bar();
|
| 92 | + |
| 93 | + // ok |
| 94 | + const y = A.from && (A.from as Function) !== B.from ? true : false; |
| 95 | + y; |
| 96 | + |
| 97 | + const x1 = { |
| 98 | + a: { b: { c: () => {} } } |
| 99 | + } |
| 100 | + const x2 = { |
| 101 | + a: { b: { c: () => {} } } |
| 102 | + } |
| 103 | + |
| 104 | + // error |
| 105 | + x1.a.b.c && x2.a.b.c(); |
| 106 | + ~~~~~~~~ |
| 107 | +!!! error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead? |
80 | 108 | }
|
81 | 109 |
|
82 | 110 | class Foo {
|
|
0 commit comments