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

Error when chaining shortcut methods #179

Closed
DanielSWolf opened this issue Sep 5, 2022 · 3 comments · Fixed by #180
Closed

Error when chaining shortcut methods #179

DanielSWolf opened this issue Sep 5, 2022 · 3 comments · Fixed by #180
Assignees

Comments

@DanielSWolf
Copy link

According to the TypeScript typings of moize, most methods and properties on the Moize type in turn return a Moize instance. This means that the following calls are syntactically valid:

const foo = moize.infinite.deep(fn);
const bar = moize.deep.maxSize(5)(fn);

Expected behavior:

These calls work and return memoized functions with two options applied

Actual behavior:

Both lines throw an error:

  • TypeError: _moize.default.infinite.deep is not a function
  • TypeError: _moize.default.deep.maxSize is not a function
@planttheidea
Copy link
Owner

Ah yes, this is a gap in the typing. Those methods are not intended to be chainable. I'll work on a fix for it sometimes this week.

In the meantime, I would recommend using the second parameter of options instead of chaining if you want to combine multiple options.

const foo = moize(fn, { isDeepEqual: true, maxSize: 5 });

@planttheidea
Copy link
Owner

I've created the PR above to resolve the issue, but going to sit on it for a day or two to review it with a fresh set of eyes.

@planttheidea
Copy link
Owner

This should be fixed as-of 6.1.3. If you have any more issues, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants