1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
=== tests/cases/compiler/overloadedConstructorFixesInferencesAppropriately.ts ===
interface Box<T> {
v: T;
>v : T
}
interface ErrorResult {
readonly error: true
>error : true
>true : true
}
interface AsyncLoaderProps<TResult extends {}> {
readonly asyncLoad: () => Box<TResult>;
>asyncLoad : () => Box<TResult>
readonly children: (result: Exclude<TResult, ErrorResult>) => string;
>children : (result: Exclude<TResult, ErrorResult>) => string
>result : Exclude<TResult, ErrorResult>
}
class AsyncLoader<TResult extends {}> {
>AsyncLoader : AsyncLoader<TResult>
constructor(props: string, context: any);
>props : string
>context : any
constructor(props: AsyncLoaderProps<TResult>);
>props : AsyncLoaderProps<TResult>
constructor(...args: any[]) {}
>args : any[]
}
function load(): Box<{ success: true } | ErrorResult> {
>load : () => Box<{ success: true;} | ErrorResult>
>success : true
>true : true
return null as any;
>null as any : any
>null : null
}
new AsyncLoader({
>new AsyncLoader({ asyncLoad: load, children: result => result.success as any,}) : AsyncLoader<ErrorResult | { success: true; }>
>AsyncLoader : typeof AsyncLoader
>{ asyncLoad: load, children: result => result.success as any,} : { asyncLoad: () => Box<ErrorResult | { success: true; }>; children: (result: { success: true; }) => any; }
asyncLoad: load,
>asyncLoad : () => Box<ErrorResult | { success: true; }>
>load : () => Box<ErrorResult | { success: true; }>
children: result => result.success as any,
>children : (result: { success: true; }) => any
>result => result.success as any : (result: { success: true; }) => any
>result : { success: true; }
>result.success as any : any
>result.success : true
>result : { success: true; }
>success : true
}); // should work fine
|