reselect icon indicating copy to clipboard operation
reselect copied to clipboard

Allow variadic dependencies as well as an array

Open ccapndave opened this issue 11 years ago • 5 comments

As well as the current system of createSelector([a, b, c], (a, b, c) => ...) it would be great if it would also be possible to do createSelector(a, b, c, (a, b, c) => ...)

This would allow us to implement robust and strictly typed Typescript definitions on createSelector.

ccapndave avatar Aug 17 '15 17:08 ccapndave

Oh, very interesting. The issue is that all the values in the array have to have the same type?

ellbee avatar Aug 17 '15 21:08 ellbee

Exactly (or you can specify a union type, but not the order they come in). If they are separate arguments they can be individually typed. This is how Rx gets such good typing in Typescript for functions such as combineLatest.

ccapndave avatar Aug 17 '15 21:08 ccapndave

Ok, thanks. I don't see why we shouldn't do this. @faassen?

ellbee avatar Aug 17 '15 21:08 ellbee

@ccapndave @ellbee Sounds interesting to me. I think it has two more advantages:

  • it deals with a common mistake that array brackets are ommited.
  • ommiting the array brackets makes it imho more readable.

speedskater avatar Aug 18 '15 07:08 speedskater

Variadic dependencies added to the 1.0.0 release

ellbee avatar Sep 09 '15 20:09 ellbee