diff --git a/snapshots/npm-ramda.ts b/snapshots/npm-ramda.ts index 239dad7..e7a6fe3 100644 --- a/snapshots/npm-ramda.ts +++ b/snapshots/npm-ramda.ts @@ -278,7 +278,7 @@ class F2 { /* pipeP */ () => { - // @dts-jest $ExpectType Promise -> PromiseLike + // @dts-jest $ExpectType Promise -> PromiseLike R.pipeP( (m: number) => Promise.resolve(R.multiply(2, m)), (m: number) => Promise.resolve(m / 2), @@ -511,7 +511,7 @@ class F2 { let lastTwo = function(val: number, idx: number, list: number[]) { return list.length - idx <= 2; }; - // @dts-jest $ExpectType number[] -> Dictionary + // @dts-jest $ExpectType number[] -> any filterIndexed(lastTwo, [8, 6, 7, 5, 3, 0, 9]); // => [0, 9] let isOdd = function(n: number) { @@ -620,15 +620,15 @@ class F2 { R.append('tests', ['write', 'more']); // => ['write', 'more', 'tests'] // @dts-jest $ExpectType string[] -> string[] R.append('tests')(['write', 'more']); // => ['write', 'more', 'tests'] - // @dts-jest $ExpectType string[] -> "tests"[] + // @dts-jest $ExpectType string[] -> string[] R.append('tests', []); // => ['tests'] - // @dts-jest $ExpectType Array -> Expected 1 type arguments, but got 2. + // @dts-jest $ExpectType Array -> Argument of type 'string[]' is not assignable to parameter of type 'string'. R.append(['tests'], ['write', 'more']); // => ['write', 'more', ['tests']] - // @dts-jest $ExpectType Array -> Argument of type 'string[]' is not assignable to parameter of type 'List'. + // @dts-jest $ExpectType Array -> (string | string[])[] R.append(['tests'], ['write', 'more']); // => ['write', 'more', ['tests']] - // @dts-jest $ExpectType Array -> Argument of type 'string[]' is not assignable to parameter of type 'List'. + // @dts-jest $ExpectType Array -> (string | string[])[] R.append(['tests'])(['write', 'more']); // => ['write', 'more', ['tests']] - // @dts-jest $ExpectType Array -> Argument of type 'string[]' is not assignable to parameter of type 'List'. + // @dts-jest $ExpectType Array -> (string | string[])[] R.append(['tests'])(['write', 'more']); // => ['write', 'more', ['tests']] }; @@ -758,14 +758,14 @@ class F2 { let isEvenFn = R.filter(isEven); isEvenFn([1, 2, 3, 4]); // ... but also objects - // @dts-jest $ExpectType Dictionary -> Dictionary + // @dts-jest $ExpectType Dictionary -> Partial<{ a: number; b: number; c: number; d: number; }> R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); // => {b: 2, d: 4} let isEvenFnObj = R.filter(isEven); // see that we did not break anything // and we kept type information // @dts-jest $ExpectType number[] -> number[] onlyNumberList(R.filter(isEven,[1,2,3,4])); - // @dts-jest $ExpectType Dictionary -> { [key: string]: number; } + // @dts-jest $ExpectType Dictionary -> Argument of type 'Partial<{ a: number; b: number; c: number; d: number; }>' is not assignable to parameter of type '{ [key: string]: number; }'. onlyNumberObj(R.filter(isEven, {a: 1, b: 2, c: 3, d: 4})); // strictNullChecks: Partial fails, consider Pick }; @@ -776,19 +776,19 @@ class F2 { }; let filterIndexed = R.addIndex(R.filter); - // @dts-jest $ExpectType number[] -> Dictionary + // @dts-jest $ExpectType number[] -> any filterIndexed(lastTwo, [8, 6, 7, 5, 3, 0, 9]); // => [0, 9] let lastTwoFn = filterIndexed(lastTwo); - // @dts-jest $ExpectType number[] -> Dictionary + // @dts-jest $ExpectType number[] -> any lastTwoFn([8, 6, 7, 5, 3, 0, 9]); }; // find, propEq () => { let xs = [{a: 1}, {a: 2}, {a: 3}]; - // @dts-jest $ExpectType Dictionary -> any + // @dts-jest $ExpectType Dictionary -> {} | undefined R.find(R.propEq('a', 2))(xs); // => {a: 2} - // @dts-jest $ExpectType undefined -> any + // @dts-jest $ExpectType undefined -> {} | undefined R.find(R.propEq('a', 4))(xs); // => undefined }; @@ -819,9 +819,9 @@ class F2 { // findLast () => { let xs = [{a: 1, b: 0}, {a: 1, b: 1}]; - // @dts-jest $ExpectType Dictionary -> any + // @dts-jest $ExpectType Dictionary -> {} | undefined R.findLast(R.propEq('a', 1))(xs); // => {a: 1, b: 1} - // @dts-jest $ExpectType undefined -> any + // @dts-jest $ExpectType undefined -> {} | undefined R.findLast(R.propEq('a', 4))(xs); // => undefined }; @@ -843,7 +843,7 @@ class F2 { let user3 = { name: 'Bob' }; let users = [ user1, user2, user3 ]; let isFamous = R.pathEq(['address', 'zipCode'], 90210); - // @dts-jest $ExpectType Object[] -> any[] + // @dts-jest $ExpectType Object[] -> {}[] R.filter(isFamous, users); // => [ user1 ] }; @@ -1056,17 +1056,17 @@ interface Obj { a: number; b: number; }; let transducer = R.compose(R.map(R.add(1)), R.take(2)); - // @dts-jest $ExpectType number[] -> Record + // @dts-jest $ExpectType number[] -> number[] | Functor | Record R.into([], transducer, numbers); // => [2, 3] - // @dts-jest $ExpectType number[] -> Argument of type '(v1: List) => Record' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. + // @dts-jest $ExpectType number[] -> Argument of type '(v1: string | any[] | ArrayLike) => map_mixed_11' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. R.into([])(transducer, numbers); // => [2, 3] - // @dts-jest $ExpectType number[] -> Record + // @dts-jest $ExpectType number[] -> number[] | Functor | Record R.into([], transducer)(numbers); // => [2, 3] let intoArray = R.into([]); - // @dts-jest $ExpectType number[] -> Argument of type '(v1: List) => Record' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. + // @dts-jest $ExpectType number[] -> Argument of type '(v1: string | any[] | ArrayLike) => map_mixed_11' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. intoArray(transducer, numbers); // => [2, 3] - // @dts-jest $ExpectType number[] -> Argument of type '(v1: List) => Record' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. + // @dts-jest $ExpectType number[] -> Argument of type '(v1: string | any[] | ArrayLike) => map_mixed_11' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. intoArray(transducer)(numbers); // => [2, 3] }; @@ -1190,9 +1190,9 @@ interface Obj { a: number; b: number; }; } return elt; }; - // @dts-jest $ExpectType number[] -> Record + // @dts-jest $ExpectType number[] -> any[] | Functor | Record R.addIndex(R.map)(squareEnds, [8, 5, 3, 0, 9]); // => [64, 5, 3, 0, 81] - // @dts-jest $ExpectType number[] -> Record + // @dts-jest $ExpectType number[] -> any[] | Functor | Record R.addIndex(R.map)(squareEnds)([8, 5, 3, 0, 9]); // => [64, 5, 3, 0, 81] }; @@ -1229,7 +1229,7 @@ interface Obj { a: number; b: number; }; R.partition((x: number) => x > 2, [1, 2, 3, 4]); // @dts-jest $ExpectType [number[], number[]] -> [number[], number[]] R.partition((x: number) => x > 2)([1, 2, 3, 4]); - // @dts-jest $ExpectType Object[] -> [Record>, Record>] + // @dts-jest $ExpectType Object[] -> [Partial<{ a: string; b: string; foo: string; }>, Partial<{ a: string; b: string; foo: string; }>] R.partition(R.contains('s'),{ a: 'sss', b: 'ttt', foo: 'bars' }); // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] }; @@ -1558,13 +1558,13 @@ type Pair = KeyValuePair; let numbers = [1, 2, 3, 4]; let transducer = R.compose(R.map(R.add(1)), R.take(2)); let fn = R.flip(R.append); - // @dts-jest $ExpectType number[] -> Record + // @dts-jest $ExpectType number[] -> number[] | Functor | Record R.transduce(transducer, fn, [] as number[], numbers); // => [2, 3] // strictNullChecks: must annotate empty array type - // @dts-jest $ExpectType number[] -> Record + // @dts-jest $ExpectType number[] -> number[] | Functor | Record R.transduce(transducer, fn, [] as number[])(numbers); // => [2, 3] - // @dts-jest $ExpectType number[] -> Record + // @dts-jest $ExpectType number[] -> number[] | Functor | Record R.transduce(transducer, fn)([] as number[], numbers); // => [2, 3] - // @dts-jest $ExpectType number[] -> Record + // @dts-jest $ExpectType number[] -> number[] | Functor | Record R.transduce(transducer)(fn, [] as number[], numbers); // => [2, 3] }; @@ -1682,11 +1682,11 @@ type Pair = KeyValuePair; // dissoc () => { - // @dts-jest $ExpectType Dictionary -> { a: number; c: number; } + // @dts-jest $ExpectType Dictionary -> Argument of type '{ a: number; b: number; c: number; }' is not assignable to parameter of type '{ a: number; c: number; }'. R.dissoc<{a: number, c: number}>('b', {a: 1, b: 2, c: 3}); // => {a: 1, c: 3} - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; c: number; } + // @dts-jest $ExpectType Dictionary -> Pick<{ a: number; b: number; c: number; }, "a" | "c"> R.dissoc('b', {a: 1, b: 2, c: 3}); // => {a: 1, c: 3} - // @dts-jest $ExpectType Dictionary -> { a: number; c: number; } + // @dts-jest $ExpectType Dictionary -> Type '{ a: number; c: number; }' does not satisfy the constraint 'Record<"b", any>'. R.dissoc('b')<{a: number, c: number}>({a: 1, b: 2, c: 3}); // => {a: 1, c: 3} }; @@ -1702,12 +1702,12 @@ type Pair = KeyValuePair; // dissocPath () => { - // @dts-jest $ExpectType {a: {b: {}}} -> { a: { b: { c: number; }; }; } + // @dts-jest $ExpectType {a: {b: {}}} -> { a?: DeepPartial | undefined; } R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); // => {a: {b: {}}} // optionally specify return type - // @dts-jest $ExpectType {a: {b: {}}} -> { a: { b: number; }; } + // @dts-jest $ExpectType {a: {b: {}}} -> Argument of type '{ a: { b: { c: number; }; }; }' is not assignable to parameter of type '{ a: { b: number; }; }'. R.dissocPath<{a : { b: number}}>(['a', 'b', 'c'], {a: {b: {c: 42}}}); // => {a: {b: {}}} - // @dts-jest $ExpectType {a: {b: {}}} -> { a: { b: { c: number; }; }; } + // @dts-jest $ExpectType {a: {b: {}}} -> { a?: DeepPartial | undefined; } R.dissocPath(['a', 'b', 'c'])({a: {b: {c: 42}}}); // => {a: {b: {}}} }; @@ -1751,9 +1751,9 @@ type Pair = KeyValuePair; lastName: R.trim, // Will not get invoked. data: {elapsed: R.add(1), remaining: R.add(-1)} }; - // @dts-jest $ExpectType typeof tomato -> any + // @dts-jest $ExpectType typeof tomato -> Argument of type '{ firstName: string; data: { elapsed: number; remaining: number; }; id: number; }' is not assignable to parameter of type '{ firstName: string; lastName: string; data: { elapsed: number; remaining: number; }; }'. const a: typeof tomato = R.evolve(transformations, tomato); // => {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id: 123} - // @dts-jest $ExpectType typeof tomato -> any + // @dts-jest $ExpectType typeof tomato -> Argument of type '{ firstName: string; data: { elapsed: number; remaining: number; }; id: number; }' is not assignable to parameter of type '{ firstName: string; lastName: string; data: { elapsed: number; remaining: number; }; }'. const b: typeof tomato = R.evolve(transformations)(tomato); // => {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id: 123} }; @@ -1954,7 +1954,7 @@ class Rectangle { // merge () => { - // @dts-jest $ExpectType Dictionary -> { 'name': string; 'age': number; } & { 'age': number; } + // @dts-jest $ExpectType Dictionary -> Pick<{ 'name': string; 'age': number; }, "name"> & { 'age': number; } R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); // => { 'name': 'fred', 'age': 40 } let resetToDefault = R.flip(R.merge)({x: 0}); @@ -1964,15 +1964,15 @@ class Rectangle { // megeAll () => { - // @dts-jest $ExpectType Dictionary -> {} + // @dts-jest $ExpectType Dictionary -> object R.mergeAll([{foo: 1},{bar: 2},{baz: 3}]); // => {foo: 1,bar: 2,baz: 3} - // @dts-jest $ExpectType Dictionary -> {} + // @dts-jest $ExpectType Dictionary -> object R.mergeAll([{foo: 1},{foo: 2},{bar: 2}]); // => {foo: 2,bar: 2} }; // mergeWith () => { - // @dts-jest $ExpectType { a: boolean, b: boolean, values: number[] } -> {} + // @dts-jest $ExpectType { a: boolean, b: boolean, values: number[] } -> Pick<{ a: boolean; values: number[]; }, "a"> & Pick<{ b: boolean; values: number[]; }, "b"> & Record<"values", string | any[]> R.mergeWith(R.concat, { a: true, values: [10, 20] }, { b: true, values: [15, 35] }); @@ -1986,19 +1986,19 @@ class Rectangle { { a: true, thing: 'foo', values: [10, 20] }, { b: true, thing: 'bar', values: [15, 35] }); const merge = R.mergeWithKey(concatValues); - // @dts-jest $ExpectType { a: boolean, b: boolean, values: number[], thing: string } -> {} + // @dts-jest $ExpectType { a: boolean, b: boolean, values: number[], thing: string } -> Pick<{ a: boolean; thing: string; values: number[]; }, "a"> & Pick<{ b: boolean; thing: string; values: number[]; }, "b"> & Record<"values" | "thing", string> merge({ a: true, thing: 'foo', values: [10, 20] }, { b: true, thing: 'bar', values: [15, 35] }); }; // pathOr () => { - // @dts-jest $ExpectType number -> {} | "N/A" + // @dts-jest $ExpectType number -> any R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); // => 2 - // @dts-jest $ExpectType number -> string | {} + // @dts-jest $ExpectType number -> any R.pathOr('N/A', ['a', 'b'])({a: {b: 2}}); // => 2 - // @dts-jest $ExpectType number -> {} | "N/A" + // @dts-jest $ExpectType number -> any R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); // => 'N/A' - // @dts-jest $ExpectType number -> {} | { c: number; } + // @dts-jest $ExpectType number -> any R.pathOr({c: 2})(['a', 'b'], {c: {b: 2}}); // => 'N/A' }; @@ -2025,29 +2025,29 @@ class Rectangle { let isPositive = function(n: number) { return n > 0; }; - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; c: number; d: number; e: number; } + // @dts-jest $ExpectType Dictionary -> Partial<{ a: number; b: number; c: number; d: number; e: number; }> R.pickBy(isPositive, {a: 1, b: 2, c: -1, d: 0, e: 5}); // => {a: 1, b: 2, e: 5} let containsBackground = function(val: any) { return val.bgcolor; }; let colors = {1: {color: 'read'}, 2: {color: 'black', bgcolor: 'yellow'}}; - // @dts-jest $ExpectType { 2: R.Dictionary } -> { 1: { color: string; }; 2: { color: string; bgcolor: string; }; } + // @dts-jest $ExpectType { 2: R.Dictionary } -> Partial<{ 1: { color: string; }; 2: { color: string; bgcolor: string; }; }> R.pickBy(containsBackground, colors); // => {2: {color: 'black', bgcolor: 'yellow'}} let isUpperCase = function(val: number, key: string) { return key.toUpperCase() === key; }; - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; A: number; B: number; } + // @dts-jest $ExpectType Dictionary -> Partial<{ a: number; b: number; A: number; B: number; }> R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); // => {A: 3, B: 4} }; // pick () => { - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; c: number; d: number; } + // @dts-jest $ExpectType Dictionary -> Pick<{ a: number; b: number; c: number; d: number; }, "a" | "d"> R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); // => {a: 1, d: 4} // the following should errror: e/f are not keys in these objects // @dts-jest $ExpectError not keys -> any let no1 = R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); // => {a: 1} - // @dts-jest $ExpectError not keys -> any + // @dts-jest $ExpectError not keys -> Argument of type '{ a: number; b: number; c: number; d: number; }' is not assignable to parameter of type 'Record<"a" | "e" | "f", any>'. let no2 = R.pick(['a', 'e', 'f'])({a: 1, b: 2, c: 3, d: 4}); // => {a: 1} // @dts-jest $ExpectError not keys -> any let no3 = R.pick(['a', 'e', 'f'], [1, 2, 3, 4]); // => {a: 1} @@ -2065,9 +2065,9 @@ class Rectangle { // omit () => { - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; c: number; d: number; } + // @dts-jest $ExpectType Dictionary -> Partial<{ a: number; b: number; c: number; d: number; }> R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); // => {b: 2, c: 3} - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; c: number; d: number; } + // @dts-jest $ExpectType Dictionary -> Partial<{ a: number; b: number; c: number; d: number; }> R.omit(['a', 'd'])({a: 1, b: 2, c: 3, d: 4}); // => {b: 2, c: 3} }; @@ -2096,20 +2096,20 @@ class Rectangle { // pickAll () => { - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; c: number; d: number; } + // @dts-jest $ExpectType Dictionary -> Pick<{ a: number; b: number; c: number; d: number; }, "a" | "d"> R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); // => {a: 1, d: 4} - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; c: number; d: number; } + // @dts-jest $ExpectType Dictionary -> Partial<{ a: number; b: number; c: number; d: number; }> R.pickAll(['a', 'd'])({a: 1, b: 2, c: 3, d: 4}); // => {a: 1, d: 4} - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; c: number; d: number; } + // @dts-jest $ExpectType Dictionary -> Partial<{ a: number; b: number; c: number; d: number; }> R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); // => {a: 1, e: undefined, f: undefined} - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; c: number; d: number; } + // @dts-jest $ExpectType Dictionary -> Partial<{ a: number; b: number; c: number; d: number; }> R.pickAll(['a', 'e', 'f'])({a: 1, b: 2, c: 3, d: 4}); // => {a: 1, e: undefined, f: undefined} // why does this pass while the above fails? }; // pickBy () => { let isUpperCase = function(val: number, key: string) { return key.toUpperCase() === key; }; - // @dts-jest $ExpectType Dictionary -> { a: number; b: number; A: number; B: number; } + // @dts-jest $ExpectType Dictionary -> Partial<{ a: number; b: number; A: number; B: number; }> R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); // => {A: 3, B: 4} }; @@ -2126,7 +2126,7 @@ class Rectangle { () => { // @dts-jest $ExpectType number -> number R.prop('x', {x: 100}); // => 100 - // @dts-jest $ExpectError Argument of type 'x' is not assignable to parameter of type 'never'. -> {} + // @dts-jest $ExpectError Argument of type 'x' is not assignable to parameter of type 'never'. -> any R.prop('x', {}); // => undefined }; @@ -2159,7 +2159,7 @@ class Rectangle { () => { // @dts-jest $ExpectType number[] -> number[] R.props(['x', 'y'], {x: 1, y: 2}); // => [1, 2] - // @dts-jest $ExpectType Array -> {}[] + // @dts-jest $ExpectType Array -> any[] R.props(['c', 'a', 'b'], {b: 2, a: 1}); // => [undefined, 1, 2] let fullName = R.compose(R.join(' '), R.props(['first', 'last'])); @@ -2495,9 +2495,9 @@ class Rectangle { // path () => { - // @dts-jest $ExpectType number -> {} + // @dts-jest $ExpectType number -> any R.path(['a', 'b'], {a: {b: 2}}); // => 2 - // @dts-jest $ExpectType number -> {} + // @dts-jest $ExpectType number -> any R.path(['a', 'b'])({a: {b: 2}}); // => 2 }; @@ -2558,21 +2558,21 @@ class Rectangle { // splitAt () => { - // @dts-jest $ExpectType number[][] -> number[][] + // @dts-jest $ExpectType number[][] -> [number[], number[]] R.splitAt(1, [1, 2, 3]); // => [[1], [2, 3]] - // @dts-jest $ExpectType number[][] -> number[][] + // @dts-jest $ExpectType number[][] -> [number[], number[]] R.splitAt(1)([1, 2, 3]); // => [[1], [2, 3]] - // @dts-jest $ExpectType string[] -> string[] + // @dts-jest $ExpectType string[] -> [string, string] R.splitAt(5, 'hello world'); // => ['hello', ' world'] - // @dts-jest $ExpectType string[] -> string[] + // @dts-jest $ExpectType string[] -> [string, string] R.splitAt(-1, 'foobar'); // => ['fooba', 'r'] }; // splitWhen () => { - // @dts-jest $ExpectType number[][] -> number[][] + // @dts-jest $ExpectType number[][] -> [number, number] R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); // => [[1], [2, 3, 1, 2, 3]] - // @dts-jest $ExpectType number[][] -> number[][] + // @dts-jest $ExpectType number[][] -> [number, number] R.splitWhen(R.equals(2))([1, 2, 3, 1, 2, 3]); // => [[1], [2, 3, 1, 2, 3]] }; @@ -3145,9 +3145,9 @@ class Why { () => { // #29 - // @dts-jest $ExpectType string[] -> string[] + // @dts-jest $ExpectType string[] -> {}[] R.pipe(R.append('a'), R.uniq)(['a', 'b', 'c']); - // @dts-jest $ExpectType string[][] -> Record + // @dts-jest $ExpectType string[][] -> string[][] | Functor | Record R.pipe( R.split(''), R.map((letter: string) => ([ letter ])) @@ -3310,12 +3310,12 @@ class Why { () => { // #119: path - // @dts-jest $ExpectType number -> {} + // @dts-jest $ExpectType number -> any R.path(['a', 'b', 'c'], {a: {b: {c: 2}}}); - // @dts-jest $ExpectType null -> {} + // @dts-jest $ExpectType null -> any R.path(['a', 'b', 'c'], {a: {b: 2}}); // still fails // let n = R.path(['a', '0', 'c'], {a: [{c: 2}] }) - // @dts-jest $ExpectType number -> {} + // @dts-jest $ExpectType number -> any R.path(['a', 0, 'c'], {a: [{c: 2}] }); }; diff --git a/tests/__snapshots__/npm-ramda.ts.snap b/tests/__snapshots__/npm-ramda.ts.snap index 8e8264e..ea69da3 100644 --- a/tests/__snapshots__/npm-ramda.ts.snap +++ b/tests/__snapshots__/npm-ramda.ts.snap @@ -14,7 +14,7 @@ exports[`$ExpectError Argument of type '{ x: string; }' is not assignable to par exports[`$ExpectError Argument of type 'null' is not assignable to parameter of type 'string'. 1`] = `"Argument of type 'null' is not assignable to parameter of type 'string'."`; -exports[`$ExpectError Argument of type 'x' is not assignable to parameter of type 'never'. 1`] = `"{}"`; +exports[`$ExpectError Argument of type 'x' is not assignable to parameter of type 'never'. 1`] = `"any"`; exports[`$ExpectError Argument of type 'x' is not assignable to parameter of type 'never'.\`, because 'x' is not in \`{}\`. 1`] = `"boolean"`; @@ -22,7 +22,10 @@ exports[`$ExpectError Supplied parameters do not match any signature of call tar exports[`$ExpectError not keys 1`] = `"any"`; -exports[`$ExpectError not keys 2`] = `"any"`; +exports[`$ExpectError not keys 2`] = ` +"Argument of type '{ a: number; b: number; c: number; d: number; }' is not assignable to parameter of type 'Record<\\"a\\" | \\"e\\" | \\"f\\", any>'. + Object literal may only specify known properties, and 'b' does not exist in type 'Record<\\"a\\" | \\"e\\" | \\"f\\", any>'." +`; exports[`$ExpectError not keys 3`] = `"any"`; @@ -136,11 +139,11 @@ exports[`$ExpectType { [s: string]: { [s: string]: number } } 1`] = `"{}"`; exports[`$ExpectType { [s: string]: { [s: string]: number } } 2`] = `"{}"`; -exports[`$ExpectType { 2: R.Dictionary } 1`] = `"{ 1: { color: string; }; 2: { color: string; bgcolor: string; }; }"`; +exports[`$ExpectType { 2: R.Dictionary } 1`] = `"Partial<{ 1: { color: string; }; 2: { color: string; bgcolor: string; }; }>"`; -exports[`$ExpectType { a: boolean, b: boolean, values: number[] } 1`] = `"{}"`; +exports[`$ExpectType { a: boolean, b: boolean, values: number[] } 1`] = `"Pick<{ a: boolean; values: number[]; }, \\"a\\"> & Pick<{ b: boolean; values: number[]; }, \\"b\\"> & Record<\\"values\\", string | any[]>"`; -exports[`$ExpectType { a: boolean, b: boolean, values: number[], thing: string } 1`] = `"{}"`; +exports[`$ExpectType { a: boolean, b: boolean, values: number[], thing: string } 1`] = `"Pick<{ a: boolean; thing: string; values: number[]; }, \\"a\\"> & Pick<{ b: boolean; thing: string; values: number[]; }, \\"b\\"> & Record<\\"values\\" | \\"thing\\", string>"`; exports[`$ExpectType { a: number }[] 1`] = `"{}[]"`; @@ -226,11 +229,17 @@ exports[`$ExpectType {(obj2: U): boolean} 1`] = `"(b: { a: number; b: number; exports[`$ExpectType {} 1`] = `"{}"`; -exports[`$ExpectType {a: {b: {}}} 1`] = `"{ a: { b: { c: number; }; }; }"`; +exports[`$ExpectType {a: {b: {}}} 1`] = `"{ a?: DeepPartial | undefined; }"`; -exports[`$ExpectType {a: {b: {}}} 2`] = `"{ a: { b: number; }; }"`; +exports[`$ExpectType {a: {b: {}}} 2`] = ` +"Argument of type '{ a: { b: { c: number; }; }; }' is not assignable to parameter of type '{ a: { b: number; }; }'. + Types of property 'a' are incompatible. + Type '{ b: { c: number; }; }' is not assignable to type '{ b: number; }'. + Types of property 'b' are incompatible. + Type '{ c: number; }' is not assignable to type 'number'." +`; -exports[`$ExpectType {a: {b: {}}} 3`] = `"{ a: { b: { c: number; }; }; }"`; +exports[`$ExpectType {a: {b: {}}} 3`] = `"{ a?: DeepPartial | undefined; }"`; exports[`$ExpectType {a: {b: {c: number}}} 1`] = `"{ a: { b: { c: number; }; }; }"`; @@ -261,26 +270,15 @@ exports[`$ExpectType Array 1`] = ` exports[`$ExpectType Array 2`] = `"Property 'set' does not exist on type 'Lens<{}, List<{}>>'."`; -exports[`$ExpectType Array 1`] = `"{}[]"`; +exports[`$ExpectType Array 1`] = `"any[]"`; -exports[`$ExpectType Array 1`] = `"Expected 1 type arguments, but got 2."`; +exports[`$ExpectType Array 1`] = `"Argument of type 'string[]' is not assignable to parameter of type 'string'."`; -exports[`$ExpectType Array 2`] = ` -"Argument of type 'string[]' is not assignable to parameter of type 'List'. - Type 'string[]' is not assignable to type 'ArrayLike'. - Index signatures are incompatible. - Type 'string' is not assignable to type 'string[]'." -`; +exports[`$ExpectType Array 2`] = `"(string | string[])[]"`; -exports[`$ExpectType Array 3`] = ` -"Argument of type 'string[]' is not assignable to parameter of type 'List'. - Type 'string[]' is not assignable to type 'ArrayLike'." -`; +exports[`$ExpectType Array 3`] = `"(string | string[])[]"`; -exports[`$ExpectType Array 4`] = ` -"Argument of type 'string[]' is not assignable to parameter of type 'List'. - Type 'string[]' is not assignable to type 'ArrayLike'." -`; +exports[`$ExpectType Array 4`] = `"(string | string[])[]"`; exports[`$ExpectType Array 5`] = `"[string, string[]]"`; @@ -322,15 +320,20 @@ exports[`$ExpectType Dictionary 3`] = `"Dictionary<{ id: string; }>"`; exports[`$ExpectType Dictionary 1`] = `"Dictionary<{ score: number; name: string; }[]>"`; -exports[`$ExpectType Dictionary 1`] = `"{ 'name': string; 'age': number; } & { 'age': number; }"`; +exports[`$ExpectType Dictionary 1`] = `"Pick<{ 'name': string; 'age': number; }, \\"name\\"> & { 'age': number; }"`; -exports[`$ExpectType Dictionary 1`] = `"Dictionary"`; +exports[`$ExpectType Dictionary 1`] = `"Partial<{ a: number; b: number; c: number; d: number; }>"`; -exports[`$ExpectType Dictionary 2`] = `"{ [key: string]: number; }"`; +exports[`$ExpectType Dictionary 2`] = ` +"Argument of type 'Partial<{ a: number; b: number; c: number; d: number; }>' is not assignable to parameter of type '{ [key: string]: number; }'. + Property 'a' is incompatible with index signature. + Type 'number | undefined' is not assignable to type 'number'. + Type 'undefined' is not assignable to type 'number'." +`; -exports[`$ExpectType Dictionary 3`] = `"any"`; +exports[`$ExpectType Dictionary 3`] = `"{} | undefined"`; -exports[`$ExpectType Dictionary 4`] = `"any"`; +exports[`$ExpectType Dictionary 4`] = `"{} | undefined"`; exports[`$ExpectType Dictionary 5`] = `"Record<\\"a\\" | \\"b\\" | \\"c\\", number>"`; @@ -352,11 +355,17 @@ exports[`$ExpectType Dictionary 13`] = `"{ a: number; b: number; } & Rec exports[`$ExpectType Dictionary 14`] = `"{ a: number; b: number; } & Record<\\"c\\", number>"`; -exports[`$ExpectType Dictionary 15`] = `"{ a: number; c: number; }"`; +exports[`$ExpectType Dictionary 15`] = ` +"Argument of type '{ a: number; b: number; c: number; }' is not assignable to parameter of type '{ a: number; c: number; }'. + Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; c: number; }'." +`; -exports[`$ExpectType Dictionary 16`] = `"{ a: number; b: number; c: number; }"`; +exports[`$ExpectType Dictionary 16`] = `"Pick<{ a: number; b: number; c: number; }, \\"a\\" | \\"c\\">"`; -exports[`$ExpectType Dictionary 17`] = `"{ a: number; c: number; }"`; +exports[`$ExpectType Dictionary 17`] = ` +"Type '{ a: number; c: number; }' does not satisfy the constraint 'Record<\\"b\\", any>'. + Property 'b' is missing in type '{ a: number; c: number; }'." +`; exports[`$ExpectType Dictionary 18`] = `"{}"`; @@ -364,31 +373,31 @@ exports[`$ExpectType Dictionary 19`] = `"{}"`; exports[`$ExpectType Dictionary 20`] = `"any"`; -exports[`$ExpectType Dictionary 21`] = `"{}"`; +exports[`$ExpectType Dictionary 21`] = `"object"`; -exports[`$ExpectType Dictionary 22`] = `"{}"`; +exports[`$ExpectType Dictionary 22`] = `"object"`; -exports[`$ExpectType Dictionary 23`] = `"{ a: number; b: number; c: number; d: number; e: number; }"`; +exports[`$ExpectType Dictionary 23`] = `"Partial<{ a: number; b: number; c: number; d: number; e: number; }>"`; -exports[`$ExpectType Dictionary 24`] = `"{ a: number; b: number; A: number; B: number; }"`; +exports[`$ExpectType Dictionary 24`] = `"Partial<{ a: number; b: number; A: number; B: number; }>"`; -exports[`$ExpectType Dictionary 25`] = `"{ a: number; b: number; c: number; d: number; }"`; +exports[`$ExpectType Dictionary 25`] = `"Pick<{ a: number; b: number; c: number; d: number; }, \\"a\\" | \\"d\\">"`; -exports[`$ExpectType Dictionary 26`] = `"{ a: number; b: number; c: number; d: number; }"`; +exports[`$ExpectType Dictionary 26`] = `"Partial<{ a: number; b: number; c: number; d: number; }>"`; -exports[`$ExpectType Dictionary 27`] = `"{ a: number; b: number; c: number; d: number; }"`; +exports[`$ExpectType Dictionary 27`] = `"Partial<{ a: number; b: number; c: number; d: number; }>"`; exports[`$ExpectType Dictionary 28`] = `"Dictionary"`; -exports[`$ExpectType Dictionary 29`] = `"{ a: number; b: number; c: number; d: number; }"`; +exports[`$ExpectType Dictionary 29`] = `"Pick<{ a: number; b: number; c: number; d: number; }, \\"a\\" | \\"d\\">"`; -exports[`$ExpectType Dictionary 30`] = `"{ a: number; b: number; c: number; d: number; }"`; +exports[`$ExpectType Dictionary 30`] = `"Partial<{ a: number; b: number; c: number; d: number; }>"`; -exports[`$ExpectType Dictionary 31`] = `"{ a: number; b: number; c: number; d: number; }"`; +exports[`$ExpectType Dictionary 31`] = `"Partial<{ a: number; b: number; c: number; d: number; }>"`; -exports[`$ExpectType Dictionary 32`] = `"{ a: number; b: number; c: number; d: number; }"`; +exports[`$ExpectType Dictionary 32`] = `"Partial<{ a: number; b: number; c: number; d: number; }>"`; -exports[`$ExpectType Dictionary 33`] = `"{ a: number; b: number; A: number; B: number; }"`; +exports[`$ExpectType Dictionary 33`] = `"Partial<{ a: number; b: number; A: number; B: number; }>"`; exports[`$ExpectType Dictionary 34`] = `"Dictionary"`; @@ -412,15 +421,15 @@ exports[`$ExpectType Object 1`] = `"{}"`; exports[`$ExpectType Object[] 1`] = `"{}[]"`; -exports[`$ExpectType Object[] 2`] = `"any[]"`; +exports[`$ExpectType Object[] 2`] = `"{}[]"`; -exports[`$ExpectType Object[] 3`] = `"[Record>, Record>]"`; +exports[`$ExpectType Object[] 3`] = `"[Partial<{ a: string; b: string; foo: string; }>, Partial<{ a: string; b: string; foo: string; }>]"`; exports[`$ExpectType Object[] 4`] = `"{}[]"`; exports[`$ExpectType Object[] 5`] = `"any[]"`; -exports[`$ExpectType Promise 1`] = `"PromiseLike"`; +exports[`$ExpectType Promise 1`] = `"PromiseLike"`; exports[`$ExpectType T 1`] = `"{ sum: number; nested: { mul: number; }; }"`; @@ -776,7 +785,7 @@ exports[`$ExpectType circle 2`] = `"R"`; exports[`$ExpectType null 1`] = `"\\"\\" | null"`; -exports[`$ExpectType null 2`] = `"{}"`; +exports[`$ExpectType null 2`] = `"any"`; exports[`$ExpectType number 1`] = `"number"`; @@ -881,13 +890,13 @@ exports[`$ExpectType number 49`] = `"{}"`; exports[`$ExpectType number 50`] = `"{}"`; -exports[`$ExpectType number 51`] = `"{} | \\"N/A\\""`; +exports[`$ExpectType number 51`] = `"any"`; -exports[`$ExpectType number 52`] = `"string | {}"`; +exports[`$ExpectType number 52`] = `"any"`; -exports[`$ExpectType number 53`] = `"{} | \\"N/A\\""`; +exports[`$ExpectType number 53`] = `"any"`; -exports[`$ExpectType number 54`] = `"{} | { c: number; }"`; +exports[`$ExpectType number 54`] = `"any"`; exports[`$ExpectType number 55`] = `"number"`; @@ -921,9 +930,9 @@ exports[`$ExpectType number 69`] = `"number"`; exports[`$ExpectType number 70`] = `"number"`; -exports[`$ExpectType number 71`] = `"{}"`; +exports[`$ExpectType number 71`] = `"any"`; -exports[`$ExpectType number 72`] = `"{}"`; +exports[`$ExpectType number 72`] = `"any"`; exports[`$ExpectType number 73`] = `"number"`; @@ -1013,9 +1022,9 @@ exports[`$ExpectType number 115`] = `"number"`; exports[`$ExpectType number 116`] = `"number"`; -exports[`$ExpectType number 117`] = `"{}"`; +exports[`$ExpectType number 117`] = `"any"`; -exports[`$ExpectType number 118`] = `"{}"`; +exports[`$ExpectType number 118`] = `"any"`; exports[`$ExpectType number[] 1`] = ` "Argument of type 'number[]' is not assignable to parameter of type 'Morphism<{}, boolean>'. @@ -1040,7 +1049,7 @@ exports[`$ExpectType number[] 9`] = `"number[]"`; exports[`$ExpectType number[] 10`] = `"number[]"`; -exports[`$ExpectType number[] 11`] = `"Dictionary"`; +exports[`$ExpectType number[] 11`] = `"any"`; exports[`$ExpectType number[] 12`] = `"number[]"`; @@ -1088,9 +1097,9 @@ exports[`$ExpectType number[] 30`] = `"number[]"`; exports[`$ExpectType number[] 31`] = `"number[]"`; -exports[`$ExpectType number[] 32`] = `"Dictionary"`; +exports[`$ExpectType number[] 32`] = `"any"`; -exports[`$ExpectType number[] 33`] = `"Dictionary"`; +exports[`$ExpectType number[] 33`] = `"any"`; exports[`$ExpectType number[] 34`] = `"number"`; @@ -1124,29 +1133,29 @@ exports[`$ExpectType number[] 48`] = `"number[]"`; exports[`$ExpectType number[] 49`] = `"number[]"`; -exports[`$ExpectType number[] 50`] = `"Record"`; +exports[`$ExpectType number[] 50`] = `"number[] | Functor | Record"`; exports[`$ExpectType number[] 51`] = ` -"Argument of type '(v1: List) => Record' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. - Type '(v1: List) => Record' is not assignable to type '(transformer: Transformer) => (accumulator: never[], value: any) => never[...'. +"Argument of type '(v1: string | any[] | ArrayLike) => map_mixed_11' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. + Type '(v1: string | any[] | ArrayLike) => map_mixed_11' is not assignable to type '(transformer: Transformer) => (accumulator: never[], value: any) => never[...'. Types of parameters 'v1' and 'transformer' are incompatible. - Type 'Transformer' is not assignable to type 'List'. + Type 'Transformer' is not assignable to type 'string | any[] | ArrayLike'. Type 'Transformer' is not assignable to type 'ArrayLike'. Property 'length' is missing in type 'Transformer'." `; -exports[`$ExpectType number[] 52`] = `"Record"`; +exports[`$ExpectType number[] 52`] = `"number[] | Functor | Record"`; exports[`$ExpectType number[] 53`] = ` -"Argument of type '(v1: List) => Record' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. - Type '(v1: List) => Record' is not assignable to type '(transformer: Transformer) => (accumulator: never[], value: any) => never[...'." +"Argument of type '(v1: string | any[] | ArrayLike) => map_mixed_11' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. + Type '(v1: string | any[] | ArrayLike) => map_mixed_11' is not assignable to type '(transformer: Transformer) => (accumulator: never[], value: any) => never[...'." `; exports[`$ExpectType number[] 54`] = ` -"Argument of type '(v1: List) => Record' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. - Type '(v1: List) => Record' is not assignable to type '(transformer: Transformer) => (accumulator: never[], value: any) => never[...'. +"Argument of type '(v1: string | any[] | ArrayLike) => map_mixed_11' is not assignable to parameter of type 'Morphism | ((transformer: Transformer) => (accumulator: ne...'. + Type '(v1: string | any[] | ArrayLike) => map_mixed_11' is not assignable to type '(transformer: Transformer) => (accumulator: never[], value: any) => never[...'. Types of parameters 'v1' and 'transformer' are incompatible. - Type 'Transformer' is not assignable to type 'List'. + Type 'Transformer' is not assignable to type 'string | any[] | ArrayLike'. Type 'Transformer' is not assignable to type 'ArrayLike'." `; @@ -1154,9 +1163,9 @@ exports[`$ExpectType number[] 55`] = `"number[]"`; exports[`$ExpectType number[] 56`] = `"number[]"`; -exports[`$ExpectType number[] 57`] = `"Record"`; +exports[`$ExpectType number[] 57`] = `"any[] | Functor | Record"`; -exports[`$ExpectType number[] 58`] = `"Record"`; +exports[`$ExpectType number[] 58`] = `"any[] | Functor | Record"`; exports[`$ExpectType number[] 59`] = `"number[]"`; @@ -1224,13 +1233,13 @@ exports[`$ExpectType number[] 90`] = `"number[]"`; exports[`$ExpectType number[] 91`] = `"number[]"`; -exports[`$ExpectType number[] 92`] = `"Record"`; +exports[`$ExpectType number[] 92`] = `"number[] | Functor | Record"`; -exports[`$ExpectType number[] 93`] = `"Record"`; +exports[`$ExpectType number[] 93`] = `"number[] | Functor | Record"`; -exports[`$ExpectType number[] 94`] = `"Record"`; +exports[`$ExpectType number[] 94`] = `"number[] | Functor | Record"`; -exports[`$ExpectType number[] 95`] = `"Record"`; +exports[`$ExpectType number[] 95`] = `"number[] | Functor | Record"`; exports[`$ExpectType number[] 96`] = `"number[]"`; @@ -1290,13 +1299,13 @@ exports[`$ExpectType number[][] 7`] = `"number[][]"`; exports[`$ExpectType number[][] 8`] = `"number[][]"`; -exports[`$ExpectType number[][] 9`] = `"number[][]"`; +exports[`$ExpectType number[][] 9`] = `"[number[], number[]]"`; -exports[`$ExpectType number[][] 10`] = `"number[][]"`; +exports[`$ExpectType number[][] 10`] = `"[number[], number[]]"`; -exports[`$ExpectType number[][] 11`] = `"number[][]"`; +exports[`$ExpectType number[][] 11`] = `"[number, number]"`; -exports[`$ExpectType number[][] 12`] = `"number[][]"`; +exports[`$ExpectType number[][] 12`] = `"[number, number]"`; exports[`$ExpectType number|any[] 1`] = `"never[] | 0"`; @@ -1462,7 +1471,7 @@ exports[`$ExpectType string[] 4`] = `"string[]"`; exports[`$ExpectType string[] 5`] = `"string[]"`; -exports[`$ExpectType string[] 6`] = `"\\"tests\\"[]"`; +exports[`$ExpectType string[] 6`] = `"string[]"`; exports[`$ExpectType string[] 7`] = `"string[]"`; @@ -1516,15 +1525,15 @@ exports[`$ExpectType string[] 31`] = `"Expected 0-2 arguments, but got 3."`; exports[`$ExpectType string[] 32`] = `"string[]"`; -exports[`$ExpectType string[] 33`] = `"string[]"`; +exports[`$ExpectType string[] 33`] = `"[string, string]"`; -exports[`$ExpectType string[] 34`] = `"string[]"`; +exports[`$ExpectType string[] 34`] = `"[string, string]"`; exports[`$ExpectType string[] 35`] = `"string[]"`; -exports[`$ExpectType string[] 36`] = `"string[]"`; +exports[`$ExpectType string[] 36`] = `"{}[]"`; -exports[`$ExpectType string[][] 1`] = `"Record"`; +exports[`$ExpectType string[][] 1`] = `"string[][] | Functor | Record"`; exports[`$ExpectType typeof people 1`] = `"any"`; @@ -1534,13 +1543,19 @@ exports[`$ExpectType typeof people 3`] = `"{}[]"`; exports[`$ExpectType typeof people 4`] = `"{}[]"`; -exports[`$ExpectType typeof tomato 1`] = `"any"`; +exports[`$ExpectType typeof tomato 1`] = ` +"Argument of type '{ firstName: string; data: { elapsed: number; remaining: number; }; id: number; }' is not assignable to parameter of type '{ firstName: string; lastName: string; data: { elapsed: number; remaining: number; }; }'. + Property 'lastName' is missing in type '{ firstName: string; data: { elapsed: number; remaining: number; }; id: number; }'." +`; -exports[`$ExpectType typeof tomato 2`] = `"any"`; +exports[`$ExpectType typeof tomato 2`] = ` +"Argument of type '{ firstName: string; data: { elapsed: number; remaining: number; }; id: number; }' is not assignable to parameter of type '{ firstName: string; lastName: string; data: { elapsed: number; remaining: number; }; }'. + Property 'lastName' is missing in type '{ firstName: string; data: { elapsed: number; remaining: number; }; id: number; }'." +`; -exports[`$ExpectType undefined 1`] = `"any"`; +exports[`$ExpectType undefined 1`] = `"{} | undefined"`; -exports[`$ExpectType undefined 2`] = `"any"`; +exports[`$ExpectType undefined 2`] = `"{} | undefined"`; exports[`$ExpectType undefined 3`] = `"string | undefined"`;