Skip to content
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

incorrect types: clearCache getting added to resultFunc return value #591

Closed
bdwain opened this issue Dec 7, 2022 · 1 comment · Fixed by #592
Closed

incorrect types: clearCache getting added to resultFunc return value #591

bdwain opened this issue Dec 7, 2022 · 1 comment · Fixed by #592

Comments

@bdwain
Copy link
Contributor

bdwain commented Dec 7, 2022

I think there are incorrect types for the resultFunc property that you can pull off of a created selector. I am on version 4.1.7

function isOdd(num: number): boolean {
  return num % 2 === 1;
}

const memoizedIsOdd = createSelector([isOdd], (bool: boolean) => bool);

memoizedIsOdd.resultFunc(true).clearCache(); //doesn't exist, but the types think it does

clearCache is only on the actual selector returned by createSelector, not the return value of result func. The types think it's on both though.

node output:

Welcome to Node.js v16.18.1.
Type ".help" for more information.
> function isOdd(num) {
...   return num % 2 === 1;
... }
undefined
>
> const { createSelector } = require('reselect')
undefined
> createSelector
[Function: createSelector]
> const memoizedIsOdd = createSelector([isOdd], (bool) => bool);
undefined
> memoizedIsOdd.resultFunc.clearCache
undefined
> memoizedIsOdd.clearCache
[Function (anonymous)]
> memoizedIsOdd.resultFunc(true)
true
> memoizedIsOdd.resultFunc(true).clearCache
undefined
> memoizedIsOdd.resultFunc(true).clearCache()
Uncaught TypeError: memoizedIsOdd.resultFunc(...).clearCache is not a function
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant