forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request microsoft#19424 from Microsoft/inferenceFromGeneri…
…cFunction Improve inference from generic functions
- Loading branch information
Showing
17 changed files
with
291 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//// [genericFunctionParameters.ts] | ||
declare function f1<T>(cb: <S>(x: S) => T): T; | ||
declare function f2<T>(cb: <S extends number>(x: S) => T): T; | ||
declare function f3<T>(cb: <S extends Array<S>>(x: S) => T): T; | ||
|
||
let x1 = f1(x => x); // {} | ||
let x2 = f2(x => x); // number | ||
let x3 = f3(x => x); // Array<any> | ||
|
||
// Repro from #19345 | ||
|
||
declare const s: <R>(go: <S>(ops: { init(): S; }) => R) => R; | ||
const x = s(a => a.init()); // x is any, should have been {} | ||
|
||
|
||
//// [genericFunctionParameters.js] | ||
"use strict"; | ||
var x1 = f1(function (x) { return x; }); // {} | ||
var x2 = f2(function (x) { return x; }); // number | ||
var x3 = f3(function (x) { return x; }); // Array<any> | ||
var x = s(function (a) { return a.init(); }); // x is any, should have been {} | ||
|
||
|
||
//// [genericFunctionParameters.d.ts] | ||
declare function f1<T>(cb: <S>(x: S) => T): T; | ||
declare function f2<T>(cb: <S extends number>(x: S) => T): T; | ||
declare function f3<T>(cb: <S extends Array<S>>(x: S) => T): T; | ||
declare let x1: {}; | ||
declare let x2: number; | ||
declare let x3: any[]; | ||
declare const s: <R>(go: <S>(ops: { | ||
init(): S; | ||
}) => R) => R; | ||
declare const x: {}; |
Oops, something went wrong.