diff --git a/snapshots/path.ts b/snapshots/path.ts index 16f893b..62cb09a 100644 --- a/snapshots/path.ts +++ b/snapshots/path.ts @@ -9,15 +9,15 @@ declare const a_1_b_2_c_3: { c: 3; }; -// @dts-jest:pass -> (object: {}) => any +// @dts-jest:pass -> (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); diff --git a/snapshots/pathOr.ts b/snapshots/pathOr.ts index 1162b94..20c15c8 100644 --- a/snapshots/pathOr.ts +++ b/snapshots/pathOr.ts @@ -5,10 +5,10 @@ declare const path: Path; declare const number: number; declare const object: object; -// @dts-jest:pass -> (object: {}) => any +// @dts-jest:pass -> (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); diff --git a/snapshots/ramda-tests.ts b/snapshots/ramda-tests.ts index 27545e2..61819f0 100644 --- a/snapshots/ramda-tests.ts +++ b/snapshots/ramda-tests.ts @@ -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 })(); @@ -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 })(); @@ -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 })(); diff --git a/templates/empty.d.ts b/templates/empty.d.ts index 26738e6..3f01f7d 100644 --- a/templates/empty.d.ts +++ b/templates/empty.d.ts @@ -1,4 +1,4 @@ export function $list(container: T[]): T[]; export function $string(container: string): string; export function $object(container: object): {}; -export function $general(container: any): any; +export function $general(container: any): T; diff --git a/templates/path.d.ts b/templates/path.d.ts index 9154efb..67d1185 100644 --- a/templates/path.d.ts +++ b/templates/path.d.ts @@ -1,3 +1,3 @@ import { Path } from './$types'; -export function $(path: Path, object: {}): any; +export function $(path: Path, object: {}): T | undefined; diff --git a/templates/pathOr.d.ts b/templates/pathOr.d.ts index ff46e1d..c618115 100644 --- a/templates/pathOr.d.ts +++ b/templates/pathOr.d.ts @@ -1,3 +1,3 @@ import { Path } from './$types'; -export function $(defaults: any, path: Path, object: {}): any; +export function $(defaults: T, path: Path, object: {}): T | U; diff --git a/templates/prop.d.ts b/templates/prop.d.ts index 36795d7..0bd21f8 100644 --- a/templates/prop.d.ts +++ b/templates/prop.d.ts @@ -8,4 +8,4 @@ export function $record>( key: K, object: T, ): T[K]; -export function $general(key: Property, object: {}): any; +export function $general(key: Property, object: {}): T | undefined; diff --git a/templates/propOr.d.ts b/templates/propOr.d.ts index 5ef00c2..6d9051b 100644 --- a/templates/propOr.d.ts +++ b/templates/propOr.d.ts @@ -10,4 +10,4 @@ export function $record>( key: K, object: T, ): T[K] | D; -export function $general(defaults: any, key: Property, object: {}): any; +export function $general(defaults: T, key: Property, object: {}): T | U; diff --git a/tests/__snapshots__/path.ts.snap b/tests/__snapshots__/path.ts.snap index 682bf8e..848c7cf 100644 --- a/tests/__snapshots__/path.ts.snap +++ b/tests/__snapshots__/path.ts.snap @@ -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`] = `"(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"`; diff --git a/tests/__snapshots__/pathOr.ts.snap b/tests/__snapshots__/pathOr.ts.snap index cba43f4..c771fdf 100644 --- a/tests/__snapshots__/pathOr.ts.snap +++ b/tests/__snapshots__/pathOr.ts.snap @@ -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`] = `"(object: {}) => number | U"`; -exports[`R_pathOr(number, path, object) 1`] = `"any"`; +exports[`R_pathOr(number, path, object) 1`] = `"number | {}"`; diff --git a/tests/__snapshots__/ramda-tests.ts.snap b/tests/__snapshots__/ramda-tests.ts.snap index bfda1b1..a7638b8 100644 --- a/tests/__snapshots__/ramda-tests.ts.snap +++ b/tests/__snapshots__/ramda-tests.ts.snap @@ -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(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"`; @@ -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"`;