-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split out optional last argument (memoizeOptions) into it's own overload #530
Split out optional last argument (memoizeOptions) into it's own overload #530
Conversation
…oad since TS can't figure out spread unions easily
Codecov Report
@@ Coverage Diff @@
## master #530 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 102 102
Branches 24 24
=========================================
Hits 102 102
|
@@ -98,7 +98,7 @@ export function createSelectorCreator< | |||
// we wrap it in an array so we can apply it. | |||
const finalMemoizeOptions = Array.isArray(memoizeOptions) | |||
? memoizeOptions | |||
: ([ memoizeOptions ] as MemoizeOptions) | |||
: ([memoizeOptions] as MemoizeOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prettier forced these changes...not sure why they were missing from the main branch...due to not wanting to battle my very opinionated IDE (and turn prettier off), I left them in.
@@ -162,8 +163,8 @@ function testInvalidTypeInCombinator() { | |||
|
|||
// does not allow heterogeneous parameter type | |||
// selectors when the combinator function is typed differently | |||
// @ts-expect-error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error is exactly the same here, just at a higher level. It still provides the same insight.
// Make sure inference of functions works... | ||
const selector3: SelectorType = createSelector(input, result) | ||
const selector4: SelectorType = createSelector(input, result, { | ||
memoizeOptions: { maxSize: 42 } | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I caught this while trying to make the examples! And the fix also solves this use case.
I'm running into similar type issues with 4.1.0.
Was reselect previously exporting |
I'm out to dinner, so can't check easily but I'm pretty sure that was removed. According to my memory, we were able to combine the type signature for the parametric selectors with the regular selectors. |
It was removed but I'd re-added it for compat purposes. Ironically RTK doesn't even use |
Fixes #526
The union type in for the
items
array in theCreateSelectorFunction
type was having difficulty discerning its type. I wrote up some examples of where TS struggles here and made a playground. Link to playground.