Merge pull request #16335 from Microsoft/delay-signature-return-type-instantiation

Delay signature return type instantiation
This commit is contained in:
Nathan Shively-Sanders 2017-06-08 09:59:48 -07:00 committed by GitHub
commit b94c51360b
5 changed files with 70 additions and 1 deletions

View File

@ -8069,7 +8069,7 @@ namespace ts {
const result = createSignature(signature.declaration, freshTypeParameters,
signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper),
instantiateList(signature.parameters, mapper, instantiateSymbol),
instantiateType(signature.resolvedReturnType, mapper),
/*resolvedReturnType*/ undefined,
freshTypePredicate,
signature.minArgumentCount, signature.hasRestParameter, signature.hasLiteralTypes);
result.target = signature;

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)