|
| 1 | +//// [declarationAsyncAndGeneratorFunctions.ts] //// |
| 2 | +export async function asyncFn() { |
| 3 | + return {} as Promise<void> |
| 4 | +} |
| 5 | + |
| 6 | +export async function asyncFn2() { |
| 7 | + return {} as number |
| 8 | +} |
| 9 | + |
| 10 | +export async function asyncFn3() { |
| 11 | + return (await 42) as number; |
| 12 | + } |
| 13 | + |
| 14 | +export function* generatorFn() { |
| 15 | + return {} as number |
| 16 | +} |
| 17 | + |
| 18 | +export async function* asyncGeneratorFn() { |
| 19 | + return {} as number |
| 20 | +} |
| 21 | +//// [declarationAsyncAndGeneratorFunctions.d.ts] //// |
| 22 | +export declare function asyncFn(): unknown; |
| 23 | +export declare function asyncFn2(): unknown; |
| 24 | +export declare function asyncFn3(): unknown; |
| 25 | +export declare function generatorFn(): {}; |
| 26 | +export declare function asyncGeneratorFn(): {}; |
| 27 | + |
| 28 | + |
| 29 | +//// [Diagnostics reported] |
| 30 | +declarationAsyncAndGeneratorFunctions.ts(1,23): error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 31 | +declarationAsyncAndGeneratorFunctions.ts(5,23): error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 32 | +declarationAsyncAndGeneratorFunctions.ts(9,23): error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 33 | +declarationAsyncAndGeneratorFunctions.ts(13,18): error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 34 | +declarationAsyncAndGeneratorFunctions.ts(17,24): error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 35 | + |
| 36 | + |
| 37 | +==== declarationAsyncAndGeneratorFunctions.ts (5 errors) ==== |
| 38 | + export async function asyncFn() { |
| 39 | + ~~~~~~~ |
| 40 | +!!! error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 41 | +!!! related TS9031 declarationAsyncAndGeneratorFunctions.ts:1:23: Add a return type to the function declaration. |
| 42 | + return {} as Promise<void> |
| 43 | + } |
| 44 | + |
| 45 | + export async function asyncFn2() { |
| 46 | + ~~~~~~~~ |
| 47 | +!!! error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 48 | +!!! related TS9031 declarationAsyncAndGeneratorFunctions.ts:5:23: Add a return type to the function declaration. |
| 49 | + return {} as number |
| 50 | + } |
| 51 | + |
| 52 | + export async function asyncFn3() { |
| 53 | + ~~~~~~~~ |
| 54 | +!!! error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 55 | +!!! related TS9031 declarationAsyncAndGeneratorFunctions.ts:9:23: Add a return type to the function declaration. |
| 56 | + return (await 42) as number; |
| 57 | + } |
| 58 | + |
| 59 | + export function* generatorFn() { |
| 60 | + ~~~~~~~~~~~ |
| 61 | +!!! error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 62 | +!!! related TS9031 declarationAsyncAndGeneratorFunctions.ts:13:18: Add a return type to the function declaration. |
| 63 | + return {} as number |
| 64 | + } |
| 65 | + |
| 66 | + export async function* asyncGeneratorFn() { |
| 67 | + ~~~~~~~~~~~~~~~~ |
| 68 | +!!! error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. |
| 69 | +!!! related TS9031 declarationAsyncAndGeneratorFunctions.ts:17:24: Add a return type to the function declaration. |
| 70 | + return {} as number |
| 71 | + } |
0 commit comments