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.

[reselect] InputSelector is not an object error with Flow 0.92.1

See original GitHub issue

Unfortunately in Flow 0.92.1, I get the following error:

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/reselect_v3.x.x.js:11:7

InputSelector [1] is not an object.

      8│     (state: TState, props: TProps, ...rest: any[]) => TResult
      9│
     10│   declare type OutputSelector<-TState, TProps, TResult> =
 [1] 11│     & InputSelector<TState, TProps, TResult>
     12│     & {
     13│       recomputations(): number,
     14│       resetRecomputations(): number,



Found 1 error

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
augusto-altmancommented, Feb 4, 2020

Hello guys,

I had the same issue and I fixed it by redefining the type OutputSelector in the file flow-typed/npm/reselect_v4.x.x.js like this:

declare type OutputSelector<-TState, TProps, TResult> = {|
    (state: TState, props: TProps, ...rest: any[]): TResult,
    recomputations(): number,
    resetRecomputations(): number,
    resultFunc(...args: any[]): TResult,
  |}

The previous definition was using type intersections and I replaced that with Flow’s calleable objects. It works and as far as I understand it achieves a more accurate typing.

image

I don’t mind to create a PR if needed.

0reactions
DmitryGoncharcommented, Mar 3, 2020

@augusto-altman Thanks a lot for the fix!) Do you think it should also be applied for the reselect_v3 types? Given that issue author mentioned flow-typed/npm/reselect_v3.x.x and that the problem nor fix do not look related to the new API in v4.

If that’s correct, do you want to create a PR or do you want me to do it?

Current libdef produces this error for us (which is fixed by your PR)

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/reselect_v3.x.x.js:12:7

A call signature declaring the expected parameter / return type is missing in object type [1] but exists in
InputSelector [2].

 [1] 12│     & {
     13│     recomputations(): number,
     14│     resetRecomputations(): number,
     15│     resultFunc(...args: any[]): TResult,
     16│     ...
     17│   };
       :
     37│     <TState, TProps, TResult, T1, T2, T3>(
     38│       selector1: InputSelector<TState, TProps, T1>,
     39│       selector2: InputSelector<TState, TProps, T2>,
 [2] 40│       selector3: InputSelector<TState, TProps, T3>,
     41│       resultFunc: (arg1: T1, arg2: T2, arg3: T3) => TResult
     42│     ): OutputSelector<TState, TProps, TResult>,
     43│     <TState, TProps, TResult, T1, T2, T3>(
Read more comments on GitHub >

github_iconTop Results From Across the Web

Reselect: createSelector not working correctly - Stack Overflow
When I dispatch an update with "adapter.updateOne", the standard selector "SelectAll" every time (i think) changes ref. Yes, you are right.
Read more >
Common Reselect Gotchas | Blog - Mastercard Developers
Reselect is a memoization library often used with Redux . ... memoize the result of the output function if the results of the...
Read more >
Building Efficient Reselect Selectors | Aug, 2020 - Medium
A walkthrough of common mistakes to avoid in your selectors, as well as some best practices to ensure they compute only when necessary....
Read more >
reselect - npm
A selector is not recomputed unless one of its arguments changes. ... mutated in a way that causes the value of an input-selector...
Read more >
Deriving Data with Selectors - Redux
You are not required to use selectors for all state lookups, ... A somewhat common mistake is to write an "input selector" that...
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