Test:inference to self-referential mapped type
From a self-referential type.
This commit is contained in:
parent
b1316e589e
commit
1068ee105d
10
tests/baselines/reference/mappedTypeRecursiveInference.js
Normal file
10
tests/baselines/reference/mappedTypeRecursiveInference.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
//// [mappedTypeRecursiveInference.ts]
|
||||
interface A { a: A }
|
||||
declare let a: A;
|
||||
type Deep<T> = { [K in keyof T]: Deep<T[K]> }
|
||||
declare function foo<T>(deep: Deep<T>): T;
|
||||
const out = foo(a);
|
||||
|
||||
|
||||
//// [mappedTypeRecursiveInference.js]
|
||||
var out = foo(a);
|
|
@ -0,0 +1,32 @@
|
|||
=== tests/cases/compiler/mappedTypeRecursiveInference.ts ===
|
||||
interface A { a: A }
|
||||
>A : Symbol(A, Decl(mappedTypeRecursiveInference.ts, 0, 0))
|
||||
>a : Symbol(A.a, Decl(mappedTypeRecursiveInference.ts, 0, 13))
|
||||
>A : Symbol(A, Decl(mappedTypeRecursiveInference.ts, 0, 0))
|
||||
|
||||
declare let a: A;
|
||||
>a : Symbol(a, Decl(mappedTypeRecursiveInference.ts, 1, 11))
|
||||
>A : Symbol(A, Decl(mappedTypeRecursiveInference.ts, 0, 0))
|
||||
|
||||
type Deep<T> = { [K in keyof T]: Deep<T[K]> }
|
||||
>Deep : Symbol(Deep, Decl(mappedTypeRecursiveInference.ts, 1, 17))
|
||||
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 2, 10))
|
||||
>K : Symbol(K, Decl(mappedTypeRecursiveInference.ts, 2, 18))
|
||||
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 2, 10))
|
||||
>Deep : Symbol(Deep, Decl(mappedTypeRecursiveInference.ts, 1, 17))
|
||||
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 2, 10))
|
||||
>K : Symbol(K, Decl(mappedTypeRecursiveInference.ts, 2, 18))
|
||||
|
||||
declare function foo<T>(deep: Deep<T>): T;
|
||||
>foo : Symbol(foo, Decl(mappedTypeRecursiveInference.ts, 2, 45))
|
||||
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 3, 21))
|
||||
>deep : Symbol(deep, Decl(mappedTypeRecursiveInference.ts, 3, 24))
|
||||
>Deep : Symbol(Deep, Decl(mappedTypeRecursiveInference.ts, 1, 17))
|
||||
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 3, 21))
|
||||
>T : Symbol(T, Decl(mappedTypeRecursiveInference.ts, 3, 21))
|
||||
|
||||
const out = foo(a);
|
||||
>out : Symbol(out, Decl(mappedTypeRecursiveInference.ts, 4, 5))
|
||||
>foo : Symbol(foo, Decl(mappedTypeRecursiveInference.ts, 2, 45))
|
||||
>a : Symbol(a, Decl(mappedTypeRecursiveInference.ts, 1, 11))
|
||||
|
33
tests/baselines/reference/mappedTypeRecursiveInference.types
Normal file
33
tests/baselines/reference/mappedTypeRecursiveInference.types
Normal file
|
@ -0,0 +1,33 @@
|
|||
=== tests/cases/compiler/mappedTypeRecursiveInference.ts ===
|
||||
interface A { a: A }
|
||||
>A : A
|
||||
>a : A
|
||||
>A : A
|
||||
|
||||
declare let a: A;
|
||||
>a : A
|
||||
>A : A
|
||||
|
||||
type Deep<T> = { [K in keyof T]: Deep<T[K]> }
|
||||
>Deep : Deep<T>
|
||||
>T : T
|
||||
>K : K
|
||||
>T : T
|
||||
>Deep : Deep<T>
|
||||
>T : T
|
||||
>K : K
|
||||
|
||||
declare function foo<T>(deep: Deep<T>): T;
|
||||
>foo : <T>(deep: Deep<T>) => T
|
||||
>T : T
|
||||
>deep : Deep<T>
|
||||
>Deep : Deep<T>
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
const out = foo(a);
|
||||
>out : { a: {}; }
|
||||
>foo(a) : { a: {}; }
|
||||
>foo : <T>(deep: Deep<T>) => T
|
||||
>a : A
|
||||
|
5
tests/cases/compiler/mappedTypeRecursiveInference.ts
Normal file
5
tests/cases/compiler/mappedTypeRecursiveInference.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
interface A { a: A }
|
||||
declare let a: A;
|
||||
type Deep<T> = { [K in keyof T]: Deep<T[K]> }
|
||||
declare function foo<T>(deep: Deep<T>): T;
|
||||
const out = foo(a);
|
Loading…
Reference in a new issue