Skip to content

Commit b94c513

Browse files
authored
Merge pull request #16335 from Microsoft/delay-signature-return-type-instantiation
Delay signature return type instantiation
2 parents 158a637 + 2eea098 commit b94c513

File tree

5 files changed

+70
-1
lines changed

5 files changed

+70
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8069,7 +8069,7 @@ namespace ts {
80698069
const result = createSignature(signature.declaration, freshTypeParameters,
80708070
signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper),
80718071
instantiateList(signature.parameters, mapper, instantiateSymbol),
8072-
instantiateType(signature.resolvedReturnType, mapper),
8072+
/*resolvedReturnType*/ undefined,
80738073
freshTypePredicate,
80748074
signature.minArgumentCount, signature.hasRestParameter, signature.hasLiteralTypes);
80758075
result.target = signature;
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)