Skip to content

Move combiner function before selector functions for type safety #366

@nickserv

Description

@nickserv

In JavaScript, spread parameters are only valid as the last parameter of a function to prevent ambiguity. Type checkers like TypeScript and Flow rely on this assumption as well for checking function argument types.

Unfortunately, even though TypeScript (as of version 3) and Flow support spread parameters, they cannot be used with Reselect's incorrect spread argument order. The combiner function is last, when it should be first so the selector functions can be a final spread parameter. This is necessary to take full advantage of all possible usages of Reselect besides the argument combinations hard coded in the TypeScript and Flow definitions, and also solves semantic confusion where Reselect has a different argument order for variable argument orders than most JavaScript APIs.

Alternatively, we could simply remove the API signatures that don't use the Array of selector functions. This would not break any code that is only using Arrays of selector functions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions