reselect icon indicating copy to clipboard operation
reselect copied to clipboard

Typescript definition files don't support alternate array argument.

Open threehams opened this issue 10 years ago • 7 comments

This is valid, and used several times in the README, but is not currently supported by definition files:

createSelector(
  [
    (state) => state.get('stuff'),
  ],
  (stuff) => {

  }
)

threehams avatar Jun 17 '16 04:06 threehams

+1

mdocter avatar Jun 23 '16 14:06 mdocter

This is turning out to be very difficult, and may not be possible. I'll keep looking at it. One approach involves doubling the size of the declaration files (taking the same approach as the current files).

threehams avatar Jun 27 '16 19:06 threehams

Oh, you know what, I think I was already aware of this, sorry! 😳

https://github.com/reactjs/reselect/issues/27

If it is impossible, maybe we should add something to the docs encouraging people to use the variadic version for type checkers.

ellbee avatar Jun 28 '16 15:06 ellbee

Got it. Today I learned about tuples.

    function createSelector<
        TInput, TProps, TOutput,
        T1,
        T2
    >(
        selectors: [
            Selector<TInput, TProps, T1>,
            Selector<TInput, TProps, T2>
        ],
        combiner: (
            arg1: T1,
            arg2: T2
        ) => TOutput
    ): Selector<TInput, TProps, TOutput>;

It's verbose, but both versions can be supported. I'll test and pull request soon.

threehams avatar Jun 28 '16 16:06 threehams

Hey, well done! Sounds good.

ellbee avatar Jun 28 '16 16:06 ellbee

https://github.com/reactjs/reselect/pull/143

threehams avatar Jun 29 '16 04:06 threehams

Going to close this as the conversation has moved to #143

ellbee avatar Jul 03 '16 14:07 ellbee