Skip to content

Commit 1068ee1

Browse files
committed
Test:inference to self-referential mapped type
From a self-referential type.
1 parent b1316e5 commit 1068ee1

4 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [mappedTypeRecursiveInference.ts]
2+
interface A { a: A }
3+
declare let a: A;
4+
type Deep<T> = { [K in keyof T]: Deep<T[K]> }
5+
declare function foo<T>(deep: Deep<T>): T;
6+
const out = foo(a);
7+
8+
9+
//// [mappedTypeRecursiveInference.js]
10+
var out = foo(a);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
=== tests/cases/compiler/mappedTypeRecursiveInference.ts ===
2+
interface A { a: A }
3+
>A : Symbol(A, Decl(mappedTypeRecursiveInference.ts, 0, 0))
4+
>a : Symbol(A.a, Decl(mappedTypeRecursiveInference.ts, 0, 13))
5+
>A : Symbol(A, Decl(mappedTypeRecursiveInference.ts, 0, 0))
6+
7+
declare let a: A;
8+
>a : Symbol(a, Decl(mappedTypeRecursiveInference.ts, 1, 11))
9+
>A : Symbol(A, Decl(mappedTypeRecursiveInference.ts, 0, 0))
10+
11+
type Deep<T> = { [K in keyof T]: Deep<T[K]> }
12+
>Deep : Symbol(Deep, Decl(mappedTypeRecursiveInference.ts, 1, 17))
13+
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 2, 10))
14+
>K : Symbol(K, Decl(mappedTypeRecursiveInference.ts, 2, 18))
15+
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 2, 10))
16+
>Deep : Symbol(Deep, Decl(mappedTypeRecursiveInference.ts, 1, 17))
17+
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 2, 10))
18+
>K : Symbol(K, Decl(mappedTypeRecursiveInference.ts, 2, 18))
19+
20+
declare function foo<T>(deep: Deep<T>): T;
21+
>foo : Symbol(foo, Decl(mappedTypeRecursiveInference.ts, 2, 45))
22+
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 3, 21))
23+
>deep : Symbol(deep, Decl(mappedTypeRecursiveInference.ts, 3, 24))
24+
>Deep : Symbol(Deep, Decl(mappedTypeRecursiveInference.ts, 1, 17))
25+
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 3, 21))
26+
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 3, 21))
27+
28+
const out = foo(a);
29+
>out : Symbol(out, Decl(mappedTypeRecursiveInference.ts, 4, 5))
30+
>foo : Symbol(foo, Decl(mappedTypeRecursiveInference.ts, 2, 45))
31+
>a : Symbol(a, Decl(mappedTypeRecursiveInference.ts, 1, 11))
32+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=== tests/cases/compiler/mappedTypeRecursiveInference.ts ===
2+
interface A { a: A }
3+
>A : A
4+
>a : A
5+
>A : A
6+
7+
declare let a: A;
8+
>a : A
9+
>A : A
10+
11+
type Deep<T> = { [K in keyof T]: Deep<T[K]> }
12+
>Deep : Deep<T>
13+
>T : T
14+
>K : K
15+
>T : T
16+
>Deep : Deep<T>
17+
>T : T
18+
>K : K
19+
20+
declare function foo<T>(deep: Deep<T>): T;
21+
>foo : <T>(deep: Deep<T>) => T
22+
>T : T
23+
>deep : Deep<T>
24+
>Deep : Deep<T>
25+
>T : T
26+
>T : T
27+
28+
const out = foo(a);
29+
>out : { a: {}; }
30+
>foo(a) : { a: {}; }
31+
>foo : <T>(deep: Deep<T>) => T
32+
>a : A
33+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface A { a: A }
2+
declare let a: A;
3+
type Deep<T> = { [K in keyof T]: Deep<T[K]> }
4+
declare function foo<T>(deep: Deep<T>): T;
5+
const out = foo(a);

0 commit comments

Comments
 (0)