-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathreverseMappedTypeRecursiveInference.types
More file actions
55 lines (45 loc) · 1.12 KB
/
reverseMappedTypeRecursiveInference.types
File metadata and controls
55 lines (45 loc) · 1.12 KB
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/compiler/reverseMappedTypeRecursiveInference.ts] ////
=== reverseMappedTypeRecursiveInference.ts ===
type Foo<V> = {
>Foo : Foo<V>
> : ^^^^^^
[K in keyof V]: Foo<V[K]>;
}
type Bar<V> = {
>Bar : Bar<V>
> : ^^^^^^
[K in keyof V]: V[K] extends object ? Bar<V[K]> : string;
}
function test<V>(value: Foo<V>): V {
>test : <V>(value: Foo<V>) => V
> : ^ ^^ ^^ ^^^^^
>value : Foo<V>
> : ^^^^^^
console.log(value);
>console.log(value) : void
> : ^^^^
>console.log : (...data: any[]) => void
> : ^^^^ ^^ ^^^^^^^^^
>console : Console
> : ^^^^^^^
>log : (...data: any[]) => void
> : ^^^^ ^^ ^^^^^^^^^
>value : Foo<V>
> : ^^^^^^
return undefined as any;
>undefined as any : any
>undefined : undefined
> : ^^^^^^^^^
}
const bar: Bar<any> = {};
>bar : Bar<any>
> : ^^^^^^^^
>{} : {}
> : ^^
test(bar);
>test(bar) : { [x: string]: any; }
> : ^^^^^^^^^^^^^^^^^^^^^
>test : <V>(value: Foo<V>) => V
> : ^ ^^ ^^ ^^^^^^
>bar : Bar<any>
> : ^^^^^^^^