Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

Commit

Permalink
test(npm-ramda): after v0.24.3-rc.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang committed Aug 10, 2017
1 parent f04562f commit f7dc2bf
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 63 deletions.
38 changes: 21 additions & 17 deletions snapshots/npm-ramda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1120,15 +1120,19 @@ interface Obj { a: number; b: number; };
// lensIndex, set, view, over
() => {
let headLens = R.lensIndex(0);
// @dts-jest $ExpectType number -> Argument of type 'number[]' is not assignable to parameter of type '(value: {}) => Functor<{}>'.
headLens([10, 20, 30, 40]); // => 10
// @dts-jest $ExpectType Array<number|string> -> Property 'set' does not exist on type 'Lens<{}, List<{}>>'.
headLens.set('mu', [10, 20, 30, 40]); // => ['mu', 20, 30, 40]
// @dts-jest $ExpectType string -> {}

// outdated types
// // @dts-jest $ExpectType number
// headLens([10, 20, 30, 40]); // => 10
// // @dts-jest $ExpectType Array<number|string>
// headLens.set('mu', [10, 20, 30, 40]); // => ['mu', 20, 30, 40]

// `any` was caused by https://github.com/gcanti/typelevel-ts/pull/7 (workaround for https://github.com/Microsoft/TypeScript/issues/15768)
// @dts-jest $ExpectType string -> any
R.view(headLens, ['a', 'b', 'c']); // => 'a'
// @dts-jest $ExpectType string[] -> {}[] | ArrayLike<{}>
// @dts-jest $ExpectType string[] -> string[]
R.set(headLens, 'x', ['a', 'b', 'c']); // => ['x', 'b', 'c']
// @dts-jest $ExpectType string[] -> {}[] | ArrayLike<{}>
// @dts-jest $ExpectType string[] -> string[]
R.over(headLens, R.toUpper, ['a', 'b', 'c']); // => ['A', 'b', 'c']
};

Expand Down Expand Up @@ -1892,22 +1896,22 @@ class Rectangle {
// lensIndex
() => {
let headLens = R.lensIndex(0);
// @dts-jest $ExpectType string -> {}
// @dts-jest $ExpectType string -> any
R.view(headLens, ['a', 'b', 'c']); // => 'a'
// @dts-jest $ExpectType string[] -> {}[] | ArrayLike<{}>
// @dts-jest $ExpectType string[] -> string[]
R.set(headLens, 'x', ['a', 'b', 'c']); // => ['x', 'b', 'c']
// @dts-jest $ExpectType string[] -> {}[] | ArrayLike<{}>
// @dts-jest $ExpectType string[] -> string[]
R.over(headLens, R.toUpper, ['a', 'b', 'c']); // => ['A', 'b', 'c']
};

// lensProp
() => {
let xLens = R.lensProp('x');
// @dts-jest $ExpectType number -> {}
// @dts-jest $ExpectType number -> number
R.view(xLens, {x: 1, y: 2}); // => 1
// @dts-jest $ExpectType Dictionary<number> -> {}
// @dts-jest $ExpectType Dictionary<number> -> { x: number; y: number; }
R.set(xLens, 4, {x: 1, y: 2}); // => {x: 4, y: 2}
// @dts-jest $ExpectType Dictionary<number> -> {}
// @dts-jest $ExpectType Dictionary<number> -> { x: number; y: number; }
R.over(xLens, R.negate, {x: 1, y: 2}); // => {x: -1, y: 2}
};

Expand Down Expand Up @@ -2121,7 +2125,7 @@ class Rectangle {
// over, lensIndex
() => {
let headLens = R.lensIndex(0);
// @dts-jest $ExpectType string[] -> {}[] | ArrayLike<{}>
// @dts-jest $ExpectType string[] -> string[]
R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); // => ['FOO', 'bar', 'baz']
};

Expand Down Expand Up @@ -2238,7 +2242,7 @@ class Rectangle {
R.where(spec, {x: 1, y: 'moo', z: true}); // => false
// @dts-jest $ExpectType boolean -> boolean
R.where(spec)({w: 10, x: 2, y: 300}); // => true
// @dts-jest $ExpectType boolean -> Argument of type '{ x: number; y: string; z: boolean; }' is not assignable to parameter of type 'Dictionary<number>'.
// @dts-jest $ExpectType boolean -> boolean
R.where(spec)({x: 1, y: 'moo', z: true}); // => false

// There's no way to represent the below functionality in typescript
Expand All @@ -2252,9 +2256,9 @@ class Rectangle {
R.where(spec2, {x: 3, y: 8}); // => true

let xs = [{x: 2, y: 1}, {x: 10, y: 2}, {x: 8, y: 3}, {x: 10, y: 4}];
// @dts-jest $ExpectType { x: number, y: number }[] -> Dictionary<number>[]
// @dts-jest $ExpectType { x: number, y: number }[] -> Dictionary<any>[]
R.filter(R.where({x: R.equals(10)}), xs); // ==> [{x: 10, y: 2}, {x: 10, y: 4}]
// @dts-jest $ExpectType { x: number, y: number }[] -> Dictionary<number>[]
// @dts-jest $ExpectType { x: number, y: number }[] -> Dictionary<any>[]
R.filter(R.where({x: R.equals(10)}))(xs); // ==> [{x: 10, y: 2}, {x: 10, y: 4}]
};

Expand Down
73 changes: 31 additions & 42 deletions tests/__snapshots__/npm-ramda.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ exports[`$ExpectType { x: number, y: number } 5`] = `"{}"`;
exports[`$ExpectType { x: number, y: number } 6`] = `"{}"`;
exports[`$ExpectType { x: number, y: number }[] 1`] = `"Dictionary<number>[]"`;
exports[`$ExpectType { x: number, y: number }[] 1`] = `"Dictionary<any>[]"`;
exports[`$ExpectType { x: number, y: number }[] 2`] = `"Dictionary<number>[]"`;
exports[`$ExpectType { x: number, y: number }[] 2`] = `"Dictionary<any>[]"`;
exports[`$ExpectType { x: number; } 1`] = `"{ x: number; }"`;
Expand Down Expand Up @@ -243,8 +243,6 @@ exports[`$ExpectType 10 1`] = `"10"`;
exports[`$ExpectType Array<number|string> 1`] = `"[string, number][]"`;
exports[`$ExpectType Array<number|string> 2`] = `"Property 'set' does not exist on type 'Lens<{}, List<{}>>'."`;
exports[`$ExpectType Array<number|undefined> 1`] = `"any[]"`;
exports[`$ExpectType Array<string[]|string> 1`] = `"(string | string[])[]"`;
Expand Down Expand Up @@ -336,9 +334,9 @@ exports[`$ExpectType Dictionary<number> 16`] = `"Pick<{ a: number; b: number; c:
exports[`$ExpectType Dictionary<number> 17`] = `"Pick<{ a: number; b: number; c: number; }, \\"a\\" | \\"c\\">"`;
exports[`$ExpectType Dictionary<number> 18`] = `"{}"`;
exports[`$ExpectType Dictionary<number> 18`] = `"{ x: number; y: number; }"`;
exports[`$ExpectType Dictionary<number> 19`] = `"{}"`;
exports[`$ExpectType Dictionary<number> 19`] = `"{ x: number; y: number; }"`;
exports[`$ExpectType Dictionary<number> 20`] = `"any"`;
Expand Down Expand Up @@ -545,11 +543,7 @@ exports[`$ExpectType boolean 60`] = `"boolean"`;
exports[`$ExpectType boolean 61`] = `"boolean"`;
exports[`$ExpectType boolean 62`] = `
"Argument of type '{ x: number; y: string; z: boolean; }' is not assignable to parameter of type 'Dictionary<number>'.
Property 'y' is incompatible with index signature.
Type 'string' is not assignable to type 'number'."
`;
exports[`$ExpectType boolean 62`] = `"boolean"`;
exports[`$ExpectType boolean 63`] = `"boolean"`;
Expand Down Expand Up @@ -803,10 +797,7 @@ exports[`$ExpectType number 40`] = `"number"`;
exports[`$ExpectType number 41`] = `"number"`;
exports[`$ExpectType number 42`] = `
"Argument of type 'number[]' is not assignable to parameter of type '(value: {}) => Functor<{}>'.
Type 'number[]' provides no match for the signature '(value: {}): Functor<{}>'."
`;
exports[`$ExpectType number 42`] = `"number"`;
exports[`$ExpectType number 43`] = `"number"`;
Expand All @@ -816,21 +807,21 @@ exports[`$ExpectType number 45`] = `"number"`;
exports[`$ExpectType number 46`] = `"number"`;
exports[`$ExpectType number 47`] = `"number"`;
exports[`$ExpectType number 47`] = `"any"`;
exports[`$ExpectType number 48`] = `"any"`;
exports[`$ExpectType number 48`] = `"number"`;
exports[`$ExpectType number 49`] = `"{}"`;
exports[`$ExpectType number 50`] = `"{}"`;
exports[`$ExpectType number 50`] = `"{} | \\"N/A\\""`;
exports[`$ExpectType number 51`] = `"{} | \\"N/A\\""`;
exports[`$ExpectType number 51`] = `"string | {}"`;
exports[`$ExpectType number 52`] = `"string | {}"`;
exports[`$ExpectType number 52`] = `"{} | \\"N/A\\""`;
exports[`$ExpectType number 53`] = `"{} | \\"N/A\\""`;
exports[`$ExpectType number 53`] = `"{} | { c: number; }"`;
exports[`$ExpectType number 54`] = `"{} | { c: number; }"`;
exports[`$ExpectType number 54`] = `"number"`;
exports[`$ExpectType number 55`] = `"number"`;
Expand Down Expand Up @@ -864,9 +855,9 @@ exports[`$ExpectType number 69`] = `"number"`;
exports[`$ExpectType number 70`] = `"number"`;
exports[`$ExpectType number 71`] = `"number"`;
exports[`$ExpectType number 71`] = `"{} | undefined"`;
exports[`$ExpectType number 72`] = `"{} | undefined"`;
exports[`$ExpectType number 72`] = `"number"`;
exports[`$ExpectType number 73`] = `"number"`;
Expand Down Expand Up @@ -896,19 +887,19 @@ exports[`$ExpectType number 85`] = `"number"`;
exports[`$ExpectType number 86`] = `"number"`;
exports[`$ExpectType number 87`] = `"number"`;
exports[`$ExpectType number 87`] = `"3 | 7"`;
exports[`$ExpectType number 88`] = `"3 | 7"`;
exports[`$ExpectType number 88`] = `"number"`;
exports[`$ExpectType number 89`] = `"number"`;
exports[`$ExpectType number 90`] = `"number"`;
exports[`$ExpectType number 91`] = `"number"`;
exports[`$ExpectType number 92`] = `"number"`;
exports[`$ExpectType number 92`] = `"3 | 9"`;
exports[`$ExpectType number 93`] = `"3 | 9"`;
exports[`$ExpectType number 93`] = `"number"`;
exports[`$ExpectType number 94`] = `"number"`;
Expand Down Expand Up @@ -938,28 +929,26 @@ exports[`$ExpectType number 106`] = `"number"`;
exports[`$ExpectType number 107`] = `"number"`;
exports[`$ExpectType number 108`] = `"number"`;
exports[`$ExpectType number 108`] = `"never[] | 0"`;
exports[`$ExpectType number 109`] = `"never[] | 0"`;
exports[`$ExpectType number 109`] = `"number | never[]"`;
exports[`$ExpectType number 110`] = `"number | never[]"`;
exports[`$ExpectType number 110`] = `"number"`;
exports[`$ExpectType number 111`] = `"number"`;
exports[`$ExpectType number 112`] = `"number"`;
exports[`$ExpectType number 113`] = `"number"`;
exports[`$ExpectType number 113`] = `"{}"`;
exports[`$ExpectType number 114`] = `"{}"`;
exports[`$ExpectType number 114`] = `"number"`;
exports[`$ExpectType number 115`] = `"number"`;
exports[`$ExpectType number 116`] = `"number"`;
exports[`$ExpectType number 117`] = `"number"`;
exports[`$ExpectType number 118`] = `"number"`;
exports[`$ExpectType number[] 1`] = `"any[] | ArrayLike<any>"`;
exports[`$ExpectType number[] 2`] = `"any[] | ArrayLike<any>"`;
Expand Down Expand Up @@ -1296,7 +1285,7 @@ exports[`$ExpectType string 29`] = `"string"`;
exports[`$ExpectType string 30`] = `"string | undefined"`;
exports[`$ExpectType string 31`] = `"{}"`;
exports[`$ExpectType string 31`] = `"any"`;
exports[`$ExpectType string 32`] = `"string | undefined"`;
Expand Down Expand Up @@ -1334,7 +1323,7 @@ exports[`$ExpectType string 48`] = `"string"`;
exports[`$ExpectType string 49`] = `"string"`;
exports[`$ExpectType string 50`] = `"{}"`;
exports[`$ExpectType string 50`] = `"any"`;
exports[`$ExpectType string 51`] = `"\\"foo\\""`;
Expand Down Expand Up @@ -1386,9 +1375,9 @@ exports[`$ExpectType string[] 9`] = `"string[]"`;
exports[`$ExpectType string[] 10`] = `"string[]"`;
exports[`$ExpectType string[] 11`] = `"{}[] | ArrayLike<{}>"`;
exports[`$ExpectType string[] 11`] = `"string[]"`;
exports[`$ExpectType string[] 12`] = `"{}[] | ArrayLike<{}>"`;
exports[`$ExpectType string[] 12`] = `"string[]"`;
exports[`$ExpectType string[] 13`] = `"string[]"`;
Expand All @@ -1410,15 +1399,15 @@ exports[`$ExpectType string[] 21`] = `"(\\"a\\" | \\"b\\" | \\"c\\")[]"`;
exports[`$ExpectType string[] 22`] = `"(\\"x\\" | \\"y\\")[]"`;
exports[`$ExpectType string[] 23`] = `"{}[] | ArrayLike<{}>"`;
exports[`$ExpectType string[] 23`] = `"string[]"`;
exports[`$ExpectType string[] 24`] = `"{}[] | ArrayLike<{}>"`;
exports[`$ExpectType string[] 24`] = `"string[]"`;
exports[`$ExpectType string[] 25`] = `"(\\"a\\" | \\"b\\" | \\"c\\")[]"`;
exports[`$ExpectType string[] 26`] = `"(\\"x\\" | \\"y\\")[]"`;
exports[`$ExpectType string[] 27`] = `"{}[] | ArrayLike<{}>"`;
exports[`$ExpectType string[] 27`] = `"string[]"`;
exports[`$ExpectType string[] 28`] = `"string[]"`;
Expand Down
12 changes: 8 additions & 4 deletions tests/npm-ramda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1120,10 +1120,14 @@ interface Obj { a: number; b: number; };
// lensIndex, set, view, over
() => {
let headLens = R.lensIndex(0);
// @dts-jest $ExpectType number
headLens([10, 20, 30, 40]); // => 10
// @dts-jest $ExpectType Array<number|string>
headLens.set('mu', [10, 20, 30, 40]); // => ['mu', 20, 30, 40]

// outdated types
// // @dts-jest $ExpectType number
// headLens([10, 20, 30, 40]); // => 10
// // @dts-jest $ExpectType Array<number|string>
// headLens.set('mu', [10, 20, 30, 40]); // => ['mu', 20, 30, 40]

// `any` was caused by https://github.com/gcanti/typelevel-ts/pull/7 (workaround for https://github.com/Microsoft/TypeScript/issues/15768)
// @dts-jest $ExpectType string
R.view(headLens, ['a', 'b', 'c']); // => 'a'
// @dts-jest $ExpectType string[]
Expand Down

0 comments on commit f7dc2bf

Please sign in to comment.