question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript typings of `EqualityFn`

See original GitHub issue

The arguments of EqualityFn are defined as being unknown even though they are known (i.e. the same as …newArgs of ResultFn).

Our build did fail today due to the recently added TypeScript types. My suggestion would be to type the args of EqualityFn as any (just like the typings on DefinitelyTyped did which does make that users do not have to cast the unknown type) or to strong-type it, e.g.:

 export type EqualityFn<Args = any> = (
  newArgs: Args,
  lastArgs: Args,
) => boolean;

export default function memoizeOne<
  ResultFn extends (this: any, ...newArgs: T) => ReturnType<ResultFn>, 
  T extends any[]
>(resultFn: ResultFn, isEqual: EqualityFn<T> = areInputsEqual): ResultFn {
...

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
alexreardoncommented, Aug 23, 2019

Fixed in 5.1.1

0reactions
alexreardoncommented, Aug 23, 2019

I think this should be fine then:

type EqualityFn = (newArgs: any[], lastArgs: any[]) => boolean;

it is fairly loose, but i don’t think the friction is worth typing it stricter for now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Advanced Types - TypeScript
Advanced concepts around types in TypeScript. ... Union types are useful for modeling situations when values can overlap in the types they can...
Read more >
React-Redux useSelector typescript type for state
In this video, Mark Erikson shows how to create some custom useAppSelector and useAppDispatch, to give them the correct types ...
Read more >
Typescript and Redux. My tips. - DEV Community ‍ ‍
Typescript and Redux. Both helps to develop fault tolerant applications. There is a lot of approaches to write typings of state and actions....
Read more >
types/react-redux/index.d.ts - UNPKG
The CDN for @types/react-redux. ... Omit taken from https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html ... 561, equalityFn?:
Read more >
reselect - npm
TypeScript icon, indicating that this package has built-in type declarations. 4.1.7 • Public • Published 9 days ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found