|
1 | 1 | tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(3,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. |
2 | | -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(95,16): error TS2378: A 'get' accessor must return a value. |
3 | | -tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(118,5): error TS1003: Identifier expected. |
| 2 | +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(93,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. |
| 3 | +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(101,17): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. |
| 4 | +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(106,16): error TS2378: A 'get' accessor must return a value. |
| 5 | +tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(129,5): error TS1003: Identifier expected. |
4 | 6 |
|
5 | 7 |
|
6 | | -==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (3 errors) ==== |
| 8 | +==== tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts (5 errors) ==== |
7 | 9 |
|
8 | 10 |
|
9 | 11 | function f1(): string { |
@@ -98,6 +100,21 @@ tests/cases/compiler/functionsMissingReturnStatementsAndExpressions.ts(118,5): e |
98 | 100 | return "Okay, not type annotated."; |
99 | 101 | } |
100 | 102 |
|
| 103 | + function f19(): void | number { |
| 104 | + ~~~~~~~~~~~~~ |
| 105 | +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. |
| 106 | + // Okay; function return type is union containing void |
| 107 | + } |
| 108 | + |
| 109 | + function f20(): any | number { |
| 110 | + // Okay; function return type is union containing any |
| 111 | + } |
| 112 | + |
| 113 | + function f21(): number | string { |
| 114 | + ~~~~~~~~~~~~~~~ |
| 115 | +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. |
| 116 | + // Not okay; union does not contain void or any |
| 117 | + } |
101 | 118 |
|
102 | 119 | class C { |
103 | 120 | public get m1() { |
|
0 commit comments