Test returning an infinite type in an intersection

This commit is contained in:
Nathan Shively-Sanders 2017-06-07 13:27:31 -07:00
parent 10beac2c1c
commit c0b8c217b1
4 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,15 @@
//// [returnInfiniteIntersection.ts]
function recursive() {
let x = <T>(subkey: T) => recursive();
return x as typeof x & { p };
}
let result = recursive()(1)
//// [returnInfiniteIntersection.js]
function recursive() {
var x = function (subkey) { return recursive(); };
return x;
}
var result = recursive()(1);

View file

@ -0,0 +1,21 @@
=== tests/cases/compiler/returnInfiniteIntersection.ts ===
function recursive() {
>recursive : Symbol(recursive, Decl(returnInfiniteIntersection.ts, 0, 0))
let x = <T>(subkey: T) => recursive();
>x : Symbol(x, Decl(returnInfiniteIntersection.ts, 1, 7))
>T : Symbol(T, Decl(returnInfiniteIntersection.ts, 1, 13))
>subkey : Symbol(subkey, Decl(returnInfiniteIntersection.ts, 1, 16))
>T : Symbol(T, Decl(returnInfiniteIntersection.ts, 1, 13))
>recursive : Symbol(recursive, Decl(returnInfiniteIntersection.ts, 0, 0))
return x as typeof x & { p };
>x : Symbol(x, Decl(returnInfiniteIntersection.ts, 1, 7))
>x : Symbol(x, Decl(returnInfiniteIntersection.ts, 1, 7))
>p : Symbol(p, Decl(returnInfiniteIntersection.ts, 2, 28))
}
let result = recursive()(1)
>result : Symbol(result, Decl(returnInfiniteIntersection.ts, 5, 3))
>recursive : Symbol(recursive, Decl(returnInfiniteIntersection.ts, 0, 0))

View file

@ -0,0 +1,27 @@
=== tests/cases/compiler/returnInfiniteIntersection.ts ===
function recursive() {
>recursive : () => (<T>(subkey: T) => any & { p: any; }) & { p: any; }
let x = <T>(subkey: T) => recursive();
>x : <T>(subkey: T) => any & { p: any; }
><T>(subkey: T) => recursive() : <T>(subkey: T) => any & { p: any; }
>T : T
>subkey : T
>T : T
>recursive() : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
>recursive : () => (<T>(subkey: T) => any & { p: any; }) & { p: any; }
return x as typeof x & { p };
>x as typeof x & { p } : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
>x : <T>(subkey: T) => any & { p: any; }
>x : <T>(subkey: T) => any & { p: any; }
>p : any
}
let result = recursive()(1)
>result : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
>recursive()(1) : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
>recursive() : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
>recursive : () => (<T>(subkey: T) => any & { p: any; }) & { p: any; }
>1 : 1

View file

@ -0,0 +1,6 @@
function recursive() {
let x = <T>(subkey: T) => recursive();
return x as typeof x & { p };
}
let result = recursive()(1)