This PR was automatically created by Snyk using the credentials of a real user.
Snyk has created this PR to upgrade reselect from 4.0.0 to 4.1.5.
![merge advice](https://app.snyk.io/badges/merge-advice/?package_manager=npm&package_name=reselect&from_version=4.0.0&to_version=4.1.5&pr_id=7fba66bf-76ef-4501-9b1e-47f16386efe9&visibility=true&has_feature_flag=false)
:information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
- The recommended version is **12 versions** ahead of your current version.
- The recommended version was released **5 months ago**, on 2021-11-24.
Release notes Package name: reselect
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
Fix intersection of parameters that are undefined by @ markerikson in #556
Export CreateSelectorFunction to fix createStructuredSelector usage by @ markerikson in #557
</li>
<li>
<b>4.1.4</b> - <a href="https://snyk.io/redirect/github/reduxjs/reselect/releases/tag/v4.1.4">2021-11-17</a></br><p>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 <code>OutputSelectorFields</code> type to improve selector variable readability, another update to parameter merging to flag nested <code>never</code> fields as compile errors, and a fix to <code>createStructuredSelector</code> parameters to resolve a lib compilation problem.</p>
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.
</li>
<li>
<b>4.1.3</b> - <a href="https://snyk.io/redirect/github/reduxjs/reselect/releases/tag/v4.1.3">2021-11-16</a></br><p>This release rewrites the TS type inference of input selector parameters for correctness, fixes inference of <code>createStructuredSelector</code> inputs, and fixes an issue with the <code>OutputSelectorFields</code> type not being exported.</p>
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:
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
Rewrite function parameter type inference to fix assorted issues by @ markerikson in #549
</li>
<li>
<b>4.1.2</b> - <a href="https://snyk.io/redirect/github/reduxjs/reselect/releases/tag/v4.1.2">2021-11-04</a></br><p>This release updates the TS types to avoid TypeScript recursion limitations and improve backwards compatibility, adds doc comments to most of the TS types and field declarations, and fixes a bug with the behavior of the <code>resultEqualityCheck</code> option in <code>defaultMemoize</code>.</p>
Changelog
TypeScript Updates
We saw cases where composition of selectors past 8-9 levels of nesting would cause TS to fail with a "Type instantiation is excessively deep and possibly infinite" error.
We've updated the types to allow additional recursion up to about 15 levels of nested selectors. Hopefully this is enough for most usages :)
The OutputSelector generic arguments had been swapped during the rewrite for 4.1, which made it incompatible with other code that attempted to import and use that type. We've reverted the generic arguments to their previous order to fix compatibility.
defaultMemoize adds a .clearCache() field to its return value. While the real caching is done by the memoizedResultFunc function, the actual returned selector has also been run through the memoizer and thus also has a .clearCache() field attached, but that wasn't captured in the types. We've updated the types to reflect that.
We've also added doc comments to almost all of the internal types for clarity, as well as comments to the returned fields on selectors.
resultEqualityCheck Behavior
The resultEqualityCheck option wasn't saving the result if there was a cache hit, which is now fixed.
What's Changed
Update defaultMemoize cache even if resultEqualityCheck is a hit by @ tetslee in #535
Make OutputSelector backwards compatible w/ < 4.1.0 version by @ eXamadeus in #536
Clarify description of createSelector by @ acrollet in #539
Clean up OutputSelector typing and fix bug with memoize function types by @ eXamadeus in #537
</li>
<li>
<b>4.1.1</b> - <a href="https://snyk.io/redirect/github/reduxjs/reselect/releases/tag/v4.1.1">2021-10-26</a></br><p>This releases fixes several TS issues and one runtime issue that were reported with the release of 4.1.0.</p>
Changelog
TypeScript Fixes
All these reported issues should now be fixed:
createSelector calls with 12 or more input selectors were causing TS to fail with a "Type instantiation is excessively deep" error. After this update, createSelector should now support up to 29 input selectors before TS has type issues. (and if you've got more than 29 input selectors.... what are you doing? :) )
Passing multiple input selectors with mismatched argument types should have been failing to compile, but was being silently accepted (ie (a: number) => 42, (b: string) => 123)
The OutputParametricSelector type, which is re-exported by Redux Toolkit, was inadvertently left out of the list of Reselect type exports during the rewrite and caused RTK builds to fail
Input selectors that were typed to return SomeType | undefined were causing the entire selector to be typed as possibly returning undefined
Caching Undefined Values
The previous internal cache logic had a couple of if (foundValue !== undefined) checks inside, but that broke cases where a selector intentionally wanted to return undefined as the actual result.
The cache logic has been updated to use an internal sentinel value as the NOT_FOUND result instead, allowing undefined to be correctly cached and returned.
What's Changed
Split out optional last argument (memoizeOptions) into it's own overload by @ eXamadeus in #530
</li>
<li>
<b>4.1.0</b> - <a href="https://snyk.io/redirect/github/reduxjs/reselect/releases/tag/v4.1.0">2021-10-26</a></br><a href="https://snyk.io/redirect/github/reduxjs/reselect/releases/tag/v4.1.0"> Read more </a>
</li>
<li>
<b>4.1.0-beta.2</b> - <a href="https://snyk.io/redirect/github/reduxjs/reselect/releases/tag/v4.1.0-beta.2">2021-10-24</a></br><p>This release fixes an issue with the <code>typesVersions</code> package field so that TS 4.1 and earlier correctly pick up the legacy type definitions - no other code changes.</p>
<div class="highlight highlight-source-shell position-relative overflow-auto" data-snippet-clipboard-copy-content="npm i reselect@next
yarn add reselect@next">
npm i reselect@next
yarn add reselect@next
Changelog
-Fix typesVersions syntax to work with TS 4.1 and earlier 4ebcc36
This PR was automatically created by Snyk using the credentials of a real user.
Snyk has created this PR to upgrade reselect from 4.0.0 to 4.1.5.
![merge advice](https://app.snyk.io/badges/merge-advice/?package_manager=npm&package_name=reselect&from_version=4.0.0&to_version=4.1.5&pr_id=7fba66bf-76ef-4501-9b1e-47f16386efe9&visibility=true&has_feature_flag=false) :information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.- The recommended version is **12 versions** ahead of your current version. - The recommended version was released **5 months ago**, on 2021-11-24.
Release notes
Package name: reselect
This release updates the TS types to correctly infer selector parameters when input selectors have
undefined
ornull
as a parameter type or have optional parameters, and exports theCreateSelectorFunction
type to fix uses ofcreateStructuredSelector
.(The types fixes feel like playing whack-a-mole, but they keep getting better!
What's Changed
Full Changelog: v4.1.4...v4.1.5
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: theCombiner
function, and aResult
type. 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 asnever
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: v4.1.3...v4.1.4
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:
<div class="highlight highlight-source-ts position-relative overflow-auto" data-snippet-clipboard-copy-content=" 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 ofnumber
andnumber | string
should be narrowed down to justnumber
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
FixesSimilarly,
createStructuredSelector
wasn't always inferring its arguments properly. We were able to reuse the parameter inference work here as well.OutputSelectorFields
ExportedThe public
OutputSelector
type depended on an internalOutputSelectorFields
type, but sinceOSF
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: v4.1.2...v4.1.3
Changelog
TypeScript Updates
We saw cases where composition of selectors past 8-9 levels of nesting would cause TS to fail with a "Type instantiation is excessively deep and possibly infinite" error.
We've updated the types to allow additional recursion up to about 15 levels of nested selectors. Hopefully this is enough for most usages :)
The
OutputSelector
generic arguments had been swapped during the rewrite for 4.1, which made it incompatible with other code that attempted to import and use that type. We've reverted the generic arguments to their previous order to fix compatibility.defaultMemoize
adds a.clearCache()
field to its return value. While the real caching is done by thememoizedResultFunc
function, the actual returned selector has also been run through the memoizer and thus also has a.clearCache()
field attached, but that wasn't captured in the types. We've updated the types to reflect that.We've also added doc comments to almost all of the internal types for clarity, as well as comments to the returned fields on selectors.
resultEqualityCheck
BehaviorThe
resultEqualityCheck
option wasn't saving the result if there was a cache hit, which is now fixed.What's Changed
New Contributors
Full Changelog: v4.1.1...v4.1.2
Changelog
TypeScript Fixes
All these reported issues should now be fixed:
createSelector
calls with 12 or more input selectors were causing TS to fail with a "Type instantiation is excessively deep" error. After this update,createSelector
should now support up to 29 input selectors before TS has type issues. (and if you've got more than 29 input selectors.... what are you doing? :) )(a: number) => 42, (b: string) => 123
)OutputParametricSelector
type, which is re-exported by Redux Toolkit, was inadvertently left out of the list of Reselect type exports during the rewrite and caused RTK builds to failSomeType | undefined
were causing the entire selector to be typed as possibly returningundefined
Caching Undefined Values
The previous internal cache logic had a couple of
if (foundValue !== undefined)
checks inside, but that broke cases where a selector intentionally wanted to returnundefined
as the actual result.The cache logic has been updated to use an internal sentinel value as the
NOT_FOUND
result instead, allowingundefined
to be correctly cached and returned.What's Changed
GetStateFromSelectors
by @ phryneas in #529undefined
by @ markerikson in #532New Contributors
Full Changelog: v4.1.0...v4.1.1
<div class="highlight highlight-source-shell position-relative overflow-auto" data-snippet-clipboard-copy-content="npm i reselect@next
yarn add reselect@next">