Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Update tests with new rest simplification
  • Loading branch information
sandersn committed Jan 13, 2017
commit 338d5aaef32981396b842a8788bf99f10efe320e
10 changes: 10 additions & 0 deletions tests/baselines/reference/differenceTypeAssignability.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,15 @@ tests/cases/conformance/types/rest/differenceTypeAssignability.ts(37,5): error T
~~~
!!! error TS2322: Type 'BN' is not assignable to type 'rest(T, "a")'.
bn = t_a; // ok, T - a still has b:any

let nest: rest(rest(T, 'a'), 'b');
let flip: rest(rest(T, 'b'), 'a');
let flat: rest(T, 'a' | 'b');
nest = flip;
nest = flat;
flip = nest;
flip = flat;
flat = nest;
flat = flip;
}

19 changes: 19 additions & 0 deletions tests/baselines/reference/differenceTypeAssignability.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ function f<T extends Abcuxyz, U extends Abcuxyz, V extends string> (t: T, u: U,
var bn: BN;
t_a = bn; // error, we have no idea what other properties T has
bn = t_a; // ok, T - a still has b:any

let nest: rest(rest(T, 'a'), 'b');
let flip: rest(rest(T, 'b'), 'a');
let flat: rest(T, 'a' | 'b');
nest = flip;
nest = flat;
flip = nest;
flip = flat;
flat = nest;
flat = flip;
}


Expand Down Expand Up @@ -65,4 +75,13 @@ function f(t, u, v) {
var bn;
t_a = bn; // error, we have no idea what other properties T has
bn = t_a; // ok, T - a still has b:any
var nest;
var flip;
var flat;
nest = flip;
nest = flat;
flip = nest;
flip = flat;
flat = nest;
flat = flip;
}
26 changes: 13 additions & 13 deletions tests/baselines/reference/objectRestNested.types
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ var other: { c: boolean };
>abc : Abc

function f<T extends Abc>(t: T) {
>f : <T extends Abc>(t: T) => rest(rest(T, "a"), "b")
>f : <T extends Abc>(t: T) => rest(T, "a" | "b")
>T : T
>Abc : Abc
>t : T
>T : T

let other: rest(rest(T, 'a'), 'b')
>other : rest(rest(T, "a"), "b")
>other : rest(T, "a" | "b")
>T : T

var { a, ...{ b, ...rest } } = t;
>a : number
>b : string
>rest : rest(rest(T, "a"), "b")
>rest : rest(T, "a" | "b")
>t : T

({ a, ...{ b, ...rest } } = t);
Expand All @@ -59,31 +59,31 @@ function f<T extends Abc>(t: T) {
>a : number
>{ b, ...rest } : any
>b : string
>rest : rest(rest(T, "a"), "b")
>rest : rest(T, "a" | "b")
>t : T

other = rest;
>other = rest : rest(rest(T, "a"), "b")
>other : rest(rest(T, "a"), "b")
>rest : rest(rest(T, "a"), "b")
>other = rest : rest(T, "a" | "b")
>other : rest(T, "a" | "b")
>rest : rest(T, "a" | "b")

rest = other;
>rest = other : rest(rest(T, "a"), "b")
>rest : rest(rest(T, "a"), "b")
>other : rest(rest(T, "a"), "b")
>rest = other : rest(T, "a" | "b")
>rest : rest(T, "a" | "b")
>other : rest(T, "a" | "b")

rest.c;
>rest.c : boolean
>rest : rest(rest(T, "a"), "b")
>rest : rest(T, "a" | "b")
>c : boolean

return rest;
>rest : rest(rest(T, "a"), "b")
>rest : rest(T, "a" | "b")
}

f({ a: 1, b: 'foo', c: false, d: 54 });
>f({ a: 1, b: 'foo', c: false, d: 54 }) : { c: false; d: number; }
>f : <T extends Abc>(t: T) => rest(rest(T, "a"), "b")
>f : <T extends Abc>(t: T) => rest(T, "a" | "b")
>{ a: 1, b: 'foo', c: false, d: 54 } : { a: number; b: string; c: false; d: number; }
>a : number
>1 : 1
Expand Down
10 changes: 10 additions & 0 deletions tests/cases/conformance/types/rest/differenceTypeAssignability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@ function f<T extends Abcuxyz, U extends Abcuxyz, V extends string> (t: T, u: U,
var bn: BN;
t_a = bn; // error, we have no idea what other properties T has
bn = t_a; // ok, T - a still has b:any

let nest: rest(rest(T, 'a'), 'b');
let flip: rest(rest(T, 'b'), 'a');
let flat: rest(T, 'a' | 'b');
nest = flip;
nest = flat;
flip = nest;
flip = flat;
flat = nest;
flat = flip;
}