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

Commit

Permalink
fix: replace returned any with T (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang authored Aug 7, 2017
1 parent 92656be commit 24f531a
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
10 changes: 5 additions & 5 deletions snapshots/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ declare const a_1_b_2_c_3: {
c: 3;
};

// @dts-jest:pass -> (object: {}) => any
// @dts-jest:pass -> <T>(object: {}) => T | undefined
R_path(path);

// @dts-jest:pass -> any
// @dts-jest:pass -> {} | undefined
R_path(path)(object);
// @dts-jest:pass -> any
// @dts-jest:pass -> {} | undefined
R_path(path, object);

// @dts-jest:pass -> any
// @dts-jest:pass -> {} | undefined
R_path(['a', 'b', 'c'])(a_1_b_2_c_3);
// @dts-jest:pass -> any
// @dts-jest:pass -> {} | undefined
R_path(['a', 'b', 'c'], a_1_b_2_c_3);
6 changes: 3 additions & 3 deletions snapshots/pathOr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ declare const path: Path;
declare const number: number;
declare const object: object;

// @dts-jest:pass -> (object: {}) => any
// @dts-jest:pass -> <U>(object: {}) => number | U
R_pathOr(number, path);

// @dts-jest:pass -> any
// @dts-jest:pass -> number | {}
R_pathOr(number)(path)(object);
// @dts-jest:pass -> any
// @dts-jest:pass -> number | {}
R_pathOr(number, path, object);
8 changes: 4 additions & 4 deletions snapshots/ramda-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ import * as R from '../ramda/dist/index';
(() => {
// @dts-jest:pass -> number
R.path(['a', 'b'], { a: { b: 2 } }); //=> 2
// @dts-jest:pass -> any
// @dts-jest:pass -> {} | undefined
R.path(['a', 'b'])({ a: { b: 2 } }); //=> 2
})();

Expand All @@ -2150,9 +2150,9 @@ import * as R from '../ramda/dist/index';

// @dts-jest:group pathOr
(() => {
// @dts-jest:pass -> any
// @dts-jest:pass -> string | {}
R.pathOr('N/A', ['a', 'b'])({ a: { b: 2 } }); //=> 2
// @dts-jest:pass -> any
// @dts-jest:pass -> string | {}
R.pathOr('N/A')(['a', 'b'], { a: { b: 2 } }); //=> 2
})();

Expand Down Expand Up @@ -2312,7 +2312,7 @@ import * as R from '../ramda/dist/index';
(() => {
// @dts-jest:pass -> number
R.prop('x', { x: 100 }); //=> 100
// @dts-jest:pass -> any
// @dts-jest:pass -> {} | undefined
R.prop('x', {}); //=> undefined
})();

Expand Down
2 changes: 1 addition & 1 deletion templates/empty.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function $list<T>(container: T[]): T[];
export function $string(container: string): string;
export function $object(container: object): {};
export function $general(container: any): any;
export function $general<T>(container: any): T;
2 changes: 1 addition & 1 deletion templates/path.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Path } from './$types';

export function $(path: Path, object: {}): any;
export function $<T>(path: Path, object: {}): T | undefined;
2 changes: 1 addition & 1 deletion templates/pathOr.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Path } from './$types';

export function $(defaults: any, path: Path, object: {}): any;
export function $<T, U>(defaults: T, path: Path, object: {}): T | U;
2 changes: 1 addition & 1 deletion templates/prop.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export function $record<K extends string, T extends Record<K, any>>(
key: K,
object: T,
): T[K];
export function $general(key: Property, object: {}): any;
export function $general<T>(key: Property, object: {}): T | undefined;
2 changes: 1 addition & 1 deletion templates/propOr.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export function $record<D, K extends string, T extends Record<K, any>>(
key: K,
object: T,
): T[K] | D;
export function $general(defaults: any, key: Property, object: {}): any;
export function $general<T, U>(defaults: T, key: Property, object: {}): T | U;
10 changes: 5 additions & 5 deletions tests/__snapshots__/path.ts.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`R_path(['a', 'b', 'c'])(a_1_b_2_c_3) 1`] = `"any"`;
exports[`R_path(['a', 'b', 'c'])(a_1_b_2_c_3) 1`] = `"{} | undefined"`;

exports[`R_path(['a', 'b', 'c'], a_1_b_2_c_3) 1`] = `"any"`;
exports[`R_path(['a', 'b', 'c'], a_1_b_2_c_3) 1`] = `"{} | undefined"`;

exports[`R_path(path) 1`] = `"(object: {}) => any"`;
exports[`R_path(path) 1`] = `"<T>(object: {}) => T | undefined"`;
exports[`R_path(path)(object) 1`] = `"any"`;
exports[`R_path(path)(object) 1`] = `"{} | undefined"`;
exports[`R_path(path, object) 1`] = `"any"`;
exports[`R_path(path, object) 1`] = `"{} | undefined"`;
6 changes: 3 additions & 3 deletions tests/__snapshots__/pathOr.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`R_pathOr(number)(path)(object) 1`] = `"any"`;
exports[`R_pathOr(number)(path)(object) 1`] = `"number | {}"`;

exports[`R_pathOr(number, path) 1`] = `"(object: {}) => any"`;
exports[`R_pathOr(number, path) 1`] = `"<U>(object: {}) => number | U"`;
exports[`R_pathOr(number, path, object) 1`] = `"any"`;
exports[`R_pathOr(number, path, object) 1`] = `"number | {}"`;
8 changes: 4 additions & 4 deletions tests/__snapshots__/ramda-tests.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -993,15 +993,15 @@ exports[`partition R.partition(R.contains('s'), ['sss', 'ttt', 'foo', 'bars']) 1
exports[`partition R.partition(R.contains('s'), { a: 'sss', b: 'ttt', foo: 'bars' }) 1`] = `"[Partial<{ a: string; b: string; foo: string; }>, Partial<{ a: string; b: string; foo: string; }>]"`;
exports[`path R.path(['a', 'b'])({ a: { b: 2 } }) 1`] = `"any"`;
exports[`path R.path(['a', 'b'])({ a: { b: 2 } }) 1`] = `"{} | undefined"`;
exports[`path R.path(['a', 'b'], { a: { b: 2 } }) 1`] = `"number"`;
exports[`pathEq R.filter<User>(isFamous, users) 1`] = `"User[]"`;
exports[`pathOr R.pathOr('N/A')(['a', 'b'], { a: { b: 2 } }) 1`] = `"any"`;
exports[`pathOr R.pathOr('N/A')(['a', 'b'], { a: { b: 2 } }) 1`] = `"string | {}"`;
exports[`pathOr R.pathOr('N/A', ['a', 'b'])({ a: { b: 2 } }) 1`] = `"any"`;
exports[`pathOr R.pathOr('N/A', ['a', 'b'])({ a: { b: 2 } }) 1`] = `"string | {}"`;
exports[`pathSatisfies R.pathSatisfies((a: any) => a !== 1, ['a', 'b', 'c'], { a: { b: { c: 2 } } }) 1`] = `"boolean"`;
Expand Down Expand Up @@ -1087,7 +1087,7 @@ exports[`project R.project(['name', 'grade'], kids) 1`] = `"Pick<{ name: string;
exports[`prop R.prop('x', { x: 100 }) 1`] = `"number"`;
exports[`prop R.prop('x', {}) 1`] = `"any"`;
exports[`prop R.prop('x', {}) 1`] = `"{} | undefined"`;
exports[`propEq R.propEq('a', '1', xs) 1`] = `"boolean"`;
Expand Down

0 comments on commit 24f531a

Please sign in to comment.