Sourced from reselect's releases.
v4.1.5
This release updates the TS types to correctly infer selector parameters when input selectors have
undefinedornullas a parameter type or have optional parameters, and exports theCreateSelectorFunctiontype to fix uses ofcreateStructuredSelector.(The types fixes feel like playing whack-a-mole, but they keep getting better!
What's Changed
- Fix intersection of parameters that are undefined by
@markeriksonin reduxjs/reselect#556- Export CreateSelectorFunction to fix createStructuredSelector usage by
@markeriksonin reduxjs/reselect#557Full Changelog: https://github.com/reduxjs/reselect/compare/v4.1.4...v4.1.5
v4.1.4
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
OutputSelectorFieldstype to improve selector variable readability, another update to parameter merging to flag nestedneverfields as compile errors, and a fix tocreateStructuredSelectorparameters 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
OutputSelectorFieldstype previously took two generics: theCombinerfunction, and aResulttype. This led to extra values being shown in hover previews for selectors. By inferringResult = 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 asneverand catch the problem at compile time. Deeper nested incompatible fields should already be caught by TS.The previous fix to
createStructuredSelectormissed a step in the spreading process, which has now been fixed.What's Changed
- Switch package management to Yarn v3 by
@markeriksonin reduxjs/reselect#551- Fix parameter expansion and improve OutputSelector readability by
@markeriksonin reduxjs/reselect#552Full Changelog: https://github.com/reduxjs/reselect/compare/v4.1.3...v4.1.4
v4.1.3
This release rewrites the TS type inference of input selector parameters for correctness, fixes inference of
createStructuredSelectorinputs, and fixes an issue with theOutputSelectorFieldstype 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:
... (truncated)
Sourced from reselect's changelog.
Change log
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
2f892bb 4.1.5901dab0 Merge pull request https://github.com/facebook/flipper/issues/557 from reduxjs/feature/csf-export9f5998e Include 4.5 in the TS test matrixad1eb08 Export CreateSelectorFunction to fix createStructuredSelector usage71e6cb6 Merge pull request https://github.com/facebook/flipper/issues/556 from reduxjs/feature/param-undefined-intersections8b920d5 Remove leftover TODO typetest comments and fix Selector usage0f4e2d2 Update param inference to handle undefined and unions correctlyd7131c0 4.1.442b6381 Merge pull request https://github.com/facebook/flipper/issues/552 from reduxjs/feature/413-ts-checks7ed20fc Fix issues with createStructuredSelector parametersThis version was pushed to npm by acemarke, a new releaser for reselect since your current version.