Skip to content

Conversation

@bowheart
Copy link
Collaborator

Description

Currently when an AtomSelectorConfig object specifies an argsComparator, Zedux infers the params type of the selector itself from the argsComparator function's parameter types.

This is a problem, especially since using Lodash's isEqual function is one of the primary use cases of argsComparator, which makes the selector's params any. And any is especially bad since it ruins all typing for the params argument of all Zedux APIs, making it easy to pass a non-array value with that selector by mistake.

Fix this by adding TypeScript's NoInfer type to the argsComparator and resultsComparator parameter types on AtomSelectorConfig. I'm not sure why resultsComparator doesn't have the same problem, but add NoInfer to that too anyway.

Add tests that reproduce the type errors and confirm the fix.

@bowheart bowheart merged commit 353aa74 into master Dec 5, 2025
3 of 6 checks passed
@bowheart bowheart deleted the josh/selector-config-noinfer branch December 5, 2025 03:54
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 this pull request may close these issues.

2 participants