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
|
=== tests/cases/conformance/types/conditional/inferTypes2.ts ===
// Repros from #22755
export declare function foo<T>(obj: T): T extends () => infer P ? P : never;
>foo : Symbol(foo, Decl(inferTypes2.ts, 0, 0))
>T : Symbol(T, Decl(inferTypes2.ts, 2, 28))
>obj : Symbol(obj, Decl(inferTypes2.ts, 2, 31))
>T : Symbol(T, Decl(inferTypes2.ts, 2, 28))
>T : Symbol(T, Decl(inferTypes2.ts, 2, 28))
>P : Symbol(P, Decl(inferTypes2.ts, 2, 61))
>P : Symbol(P, Decl(inferTypes2.ts, 2, 61))
export function bar<T>(obj: T) {
>bar : Symbol(bar, Decl(inferTypes2.ts, 2, 76))
>T : Symbol(T, Decl(inferTypes2.ts, 3, 20))
>obj : Symbol(obj, Decl(inferTypes2.ts, 3, 23))
>T : Symbol(T, Decl(inferTypes2.ts, 3, 20))
return foo(obj);
>foo : Symbol(foo, Decl(inferTypes2.ts, 0, 0))
>obj : Symbol(obj, Decl(inferTypes2.ts, 3, 23))
}
export type BadNested<T> = { x: T extends number ? T : string };
>BadNested : Symbol(BadNested, Decl(inferTypes2.ts, 5, 1))
>T : Symbol(T, Decl(inferTypes2.ts, 7, 22))
>x : Symbol(x, Decl(inferTypes2.ts, 7, 28))
>T : Symbol(T, Decl(inferTypes2.ts, 7, 22))
>T : Symbol(T, Decl(inferTypes2.ts, 7, 22))
export declare function foo2<T>(obj: T): T extends { [K in keyof BadNested<infer P>]: BadNested<infer P>[K] } ? P : never;
>foo2 : Symbol(foo2, Decl(inferTypes2.ts, 7, 64))
>T : Symbol(T, Decl(inferTypes2.ts, 9, 29))
>obj : Symbol(obj, Decl(inferTypes2.ts, 9, 32))
>T : Symbol(T, Decl(inferTypes2.ts, 9, 29))
>T : Symbol(T, Decl(inferTypes2.ts, 9, 29))
>K : Symbol(K, Decl(inferTypes2.ts, 9, 54))
>BadNested : Symbol(BadNested, Decl(inferTypes2.ts, 5, 1))
>P : Symbol(P, Decl(inferTypes2.ts, 9, 80), Decl(inferTypes2.ts, 9, 101))
>BadNested : Symbol(BadNested, Decl(inferTypes2.ts, 5, 1))
>P : Symbol(P, Decl(inferTypes2.ts, 9, 80), Decl(inferTypes2.ts, 9, 101))
>K : Symbol(K, Decl(inferTypes2.ts, 9, 54))
>P : Symbol(P, Decl(inferTypes2.ts, 9, 80), Decl(inferTypes2.ts, 9, 101))
export function bar2<T>(obj: T) {
>bar2 : Symbol(bar2, Decl(inferTypes2.ts, 9, 122))
>T : Symbol(T, Decl(inferTypes2.ts, 10, 21))
>obj : Symbol(obj, Decl(inferTypes2.ts, 10, 24))
>T : Symbol(T, Decl(inferTypes2.ts, 10, 21))
return foo2(obj);
>foo2 : Symbol(foo2, Decl(inferTypes2.ts, 7, 64))
>obj : Symbol(obj, Decl(inferTypes2.ts, 10, 24))
}
|