Skip to content

Commit c0b8c21

Browse files
committed
Test returning an infinite type in an intersection
1 parent 10beac2 commit c0b8c21

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//// [returnInfiniteIntersection.ts]
2+
function recursive() {
3+
let x = <T>(subkey: T) => recursive();
4+
return x as typeof x & { p };
5+
}
6+
7+
let result = recursive()(1)
8+
9+
10+
//// [returnInfiniteIntersection.js]
11+
function recursive() {
12+
var x = function (subkey) { return recursive(); };
13+
return x;
14+
}
15+
var result = recursive()(1);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/returnInfiniteIntersection.ts ===
2+
function recursive() {
3+
>recursive : Symbol(recursive, Decl(returnInfiniteIntersection.ts, 0, 0))
4+
5+
let x = <T>(subkey: T) => recursive();
6+
>x : Symbol(x, Decl(returnInfiniteIntersection.ts, 1, 7))
7+
>T : Symbol(T, Decl(returnInfiniteIntersection.ts, 1, 13))
8+
>subkey : Symbol(subkey, Decl(returnInfiniteIntersection.ts, 1, 16))
9+
>T : Symbol(T, Decl(returnInfiniteIntersection.ts, 1, 13))
10+
>recursive : Symbol(recursive, Decl(returnInfiniteIntersection.ts, 0, 0))
11+
12+
return x as typeof x & { p };
13+
>x : Symbol(x, Decl(returnInfiniteIntersection.ts, 1, 7))
14+
>x : Symbol(x, Decl(returnInfiniteIntersection.ts, 1, 7))
15+
>p : Symbol(p, Decl(returnInfiniteIntersection.ts, 2, 28))
16+
}
17+
18+
let result = recursive()(1)
19+
>result : Symbol(result, Decl(returnInfiniteIntersection.ts, 5, 3))
20+
>recursive : Symbol(recursive, Decl(returnInfiniteIntersection.ts, 0, 0))
21+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
=== tests/cases/compiler/returnInfiniteIntersection.ts ===
2+
function recursive() {
3+
>recursive : () => (<T>(subkey: T) => any & { p: any; }) & { p: any; }
4+
5+
let x = <T>(subkey: T) => recursive();
6+
>x : <T>(subkey: T) => any & { p: any; }
7+
><T>(subkey: T) => recursive() : <T>(subkey: T) => any & { p: any; }
8+
>T : T
9+
>subkey : T
10+
>T : T
11+
>recursive() : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
12+
>recursive : () => (<T>(subkey: T) => any & { p: any; }) & { p: any; }
13+
14+
return x as typeof x & { p };
15+
>x as typeof x & { p } : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
16+
>x : <T>(subkey: T) => any & { p: any; }
17+
>x : <T>(subkey: T) => any & { p: any; }
18+
>p : any
19+
}
20+
21+
let result = recursive()(1)
22+
>result : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
23+
>recursive()(1) : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
24+
>recursive() : (<T>(subkey: T) => any & { p: any; }) & { p: any; }
25+
>recursive : () => (<T>(subkey: T) => any & { p: any; }) & { p: any; }
26+
>1 : 1
27+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function recursive() {
2+
let x = <T>(subkey: T) => recursive();
3+
return x as typeof x & { p };
4+
}
5+
6+
let result = recursive()(1)

0 commit comments

Comments
 (0)