Skip to content

Update dependency reselect to v4.1.5 - autoclosed

igswsihw-wmadepbot requested to merge renovate/reselect-4.x into main

This MR contains the following updates:

Package Change Age Adoption Passing Confidence
reselect 4.1.2 -> 4.1.5 age adoption passing confidence

Release Notes

reduxjs/reselect

v4.1.5

Compare Source

This release updates the TS types to correctly infer selector parameters when input selectors have undefined or null as a parameter type or have optional parameters, and exports the CreateSelectorFunction type to fix uses of createStructuredSelector.

(The types fixes feel like playing whack-a-mole, but they keep getting better!

What's Changed

Full Changelog: https://github.com/reduxjs/reselect/compare/v4.1.4...v4.1.5

v4.1.4

Compare Source

This release has (you guessed it) more fixes to the TS types: a change to parameter merging that fixes breakage with selectors and RTK Query's API state, a simplification of the OutputSelectorFields type to improve selector variable readability, another update to parameter merging to flag nested never fields as compile errors, and a fix to createStructuredSelector parameters to resolve a lib compilation problem.

Changelog

More TS Fixes

The parameter merging fixes in 4.1.3 tried to "unwrap/expand" the parameter types to make them more readable, such as showing intersected objects as {a, b, c} instead of {a} & {b} & {c}. This was done with a recursive expansion type. That turned out to break with the complex state types used by RTK Query. We've updated the type expansion to only be a single level instead, which fixes the compilation issue.

The OutputSelectorFields type previously took two generics: the Combiner function, and a Result type. This led to extra values being shown in hover previews for selectors. By inferring Result = ReturnType<Combiner>, we were able to drop the second generic and cut down on the amount of types shown in previews.

A user noted that intersected objects with top-level incompatible fields (like {a: string} & {a: number}) resulted in empty objects, but no compile error. We've updated the parameter merging to flag those as never and catch the problem at compile time. Deeper nested incompatible fields should already be caught by TS.

The previous fix to createStructuredSelector missed a step in the spreading process, which has now been fixed.

What's Changed

Full Changelog: https://github.com/reduxjs/reselect/compare/v4.1.3...v4.1.4

v4.1.3

Compare Source

This release rewrites the TS type inference of input selector parameters for correctness, fixes inference of createStructuredSelector inputs, and fixes an issue with the OutputSelectorFields type not being exported.

Changelog

Input Selector Parameter Inference Improvements

Reselect's types have always been extremely tricky, because it involves passing multiple input selectors with potentially heterogeneous, and then nested function composition of multiple selectors. Additionally, the input selectors can be passed as individual arguments or a single array of input selectors.

The 4.0.0 typedefs dealt with this by hand-writing dozens of overloads, which was absolutely impossible to maintain.

In 4.1, we took advantage of TS's improved abilities to infer array/tuple types to consolidate the typedefs.

One of the issues that happened as a result was that arguments at the same input parameter index were being "unioned" together, rather than "intersectioned". For example, in this complex selector:

  const input1 = (
    _: StateA,
    { testNumber }: { testNumber: number },
    c: number,
    d: string
  ) => testNumber

  const input2 = (
    _: StateA,
    { testString }: { testString: string },
    c: number | string
  ) => testString

  const input3 = (
    _: StateA,
    { testBoolean }: { testBoolean: boolean },
    c: number | string,
    d: string
  ) => testBoolean

  const input4 = (_: StateA, { testString2 }: { testString2: string }) =>
    testString2

  const testSelector = createSelector(
    input1,
    input2,
    input3,
    input4,
    (testNumber, testString, testBoolean) => testNumber + testString
  )

The second arg should end up as an object like {testNumber: number, testString: string, testBoolean: boolean, testString2: string}. However, it was ending up as four separate one-field objects. Similarly, the combination of number and number | string should be narrowed down to just number as an acceptable value.

We've rewritten the types to successfully accomplish that (although it took a lot of collective effort and headbanging to actually pull this off!) This should now give much more correct results when determining the final parameters that can be passed to a selector.

createStructuredSelector Fixes

Similarly, createStructuredSelector wasn't always inferring its arguments properly. We were able to reuse the parameter inference work here as well.

OutputSelectorFields Exported

The public OutputSelector type depended on an internal OutputSelectorFields type, but since OSF wasn't being exported, TS would throw errors when trying to generate declaration files that exported selectors. That is now public as well.

What's Changed

Full Changelog: https://github.com/reduxjs/reselect/compare/v4.1.2...v4.1.3


Configuration

📅 Schedule: At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this MR and you won't be reminded about this update again.


  • If you want to rebase/retry this MR, click this checkbox.

This MR has been generated by Renovate Bot.

Edited by igswsihw-wmadepbot

Merge request reports