Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
080b391
add type-level function application
KiaraGrouwstra Aug 22, 2017
312b69e
type calls: add failing test
KiaraGrouwstra Aug 22, 2017
c98fe79
disambiguate type argument lists with empty <>
KiaraGrouwstra Aug 23, 2017
636b4ac
fix function name
KiaraGrouwstra Aug 23, 2017
a76ba38
show issues: overload selection (#17471), composition
KiaraGrouwstra Aug 24, 2017
187b6b5
minimum chaining repro + checks, errors
KiaraGrouwstra Aug 25, 2017
ee110a3
allow errors on artificial nodes, empty type args
KiaraGrouwstra Aug 25, 2017
7a0ec45
Merge branch 'master' into 6606-type-level-function-application
KiaraGrouwstra Aug 26, 2017
fa39af3
switch parent linking to built-in fn.. how to import though?
KiaraGrouwstra Aug 26, 2017
6591541
fix some tests
KiaraGrouwstra Sep 3, 2017
4b2e8a1
give type calls own type, fixes eager eval
KiaraGrouwstra Sep 6, 2017
2f2e800
fix other tests
KiaraGrouwstra Sep 8, 2017
c54eea7
drop type arg support, works fine but not worth it
KiaraGrouwstra Sep 9, 2017
0e4c359
resolve type call, generalize functions to fix synthetic node workaround
KiaraGrouwstra Sep 9, 2017
c70ea67
factor out function
KiaraGrouwstra Sep 9, 2017
f730a07
drop index type... not needed here unlike for gcnew's `!`?
KiaraGrouwstra Sep 9, 2017
9bbae94
add tests
KiaraGrouwstra Sep 9, 2017
28aece0
tests: reduce/map WIP
KiaraGrouwstra Sep 9, 2017
4d14c9f
add use-case: type substraction / assertion (`!`)
KiaraGrouwstra Sep 9, 2017
a8fc55a
use-case: `promised` (WIP, breaks on unions)
KiaraGrouwstra Sep 9, 2017
ccc55d1
add tests
KiaraGrouwstra Sep 11, 2017
a7882c2
add error tests in own file
KiaraGrouwstra Sep 11, 2017
e67a82b
simplify out unused bits
KiaraGrouwstra Sep 11, 2017
5decbbc
directly pass arg types for type calls, fixes compose
KiaraGrouwstra Sep 11, 2017
d602415
union-proof type calls, fixes `awaited` use-case from #17077
KiaraGrouwstra Sep 11, 2017
e131686
fix heterogeneous map test (add type param)
KiaraGrouwstra Sep 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use-case: promised (WIP, breaks on unions)
  • Loading branch information
KiaraGrouwstra committed Sep 9, 2017
commit a8fc55a3bbc2718cd9cf2edfa2b736dd55c9d1fa
39 changes: 39 additions & 0 deletions tests/baselines/reference/typeCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,36 @@ let assert: Assert<string | undefined>; // string
type Minus<A, B> = (<U>(v: U | B) => U)(A);
let noNumbers: Minus<string | number, number>; // string

interface UnwrapPromise {
<U>(v: PromiseLike<U>): UnwrapPromise(U);
<U>(v: U): U;
};
declare const testUnwrap1: UnwrapPromise(string);
declare const testUnwrap2: UnwrapPromise(Promise<string>);
declare const testUnwrap3: UnwrapPromise(boolean | Promise<string>);
declare function myThen<T, TResult1 = T, TResult2 = never>(
prom: Promise<T>,
onfulfilled?: ((value: T) => TResult1) | undefined | null,
onrejected?: ((reason: any) => TResult2) | undefined | null
): Promise<UnwrapPromise(TResult1) | UnwrapPromise(TResult2)>;
declare const pr: Promise<number>;
declare function f(x: number): Promise<string>;
declare function g(x: number): number | Promise<boolean>;
const testThen = myThen(pr, f, g);

interface Promise<T> {
then<TResult1 = T, TResult2 = never>(
onfulfilled?: ((value: T) => TResult1) | undefined | null,
onrejected?: ((reason: any) => TResult2) | undefined | null
): Promise<UnwrapPromise(TResult1) | UnwrapPromise(TResult2)>;
}
// error: Argument of type '(x: number) => number | Promise<string>' is not assignable to parameter
// of type '(value: number) => string | PromiseLike<string>';
const tryProm = pr.then((x: number) => {
if (x < 0) return f(x);
return x;
});

interface ObjectHasStringIndex {
// <T extends { [k: string]: any }>(o: T): T[string];
(o: { [k: string]: any }): '1';
Expand Down Expand Up @@ -229,6 +259,15 @@ var anyBool; // 0
var neverBool; // 0
var assert; // string
var noNumbers; // string
;
var testThen = myThen(pr, f, g);
// error: Argument of type '(x: number) => number | Promise<string>' is not assignable to parameter
// of type '(value: number) => string | PromiseLike<string>';
var tryProm = pr.then(function (x) {
if (x < 0)
return f(x);
return x;
});
var ObjectHasStringIndexTestT; // '1'
var ObjectHasStringIndexTestF; // wanted '0', got '1'... so can't match for index, and erroring RHS yields `any`. ouch.
var a1;
Expand Down
Loading