refactor: increase typescript state resolver limit #787
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the comment by @tormodAase in regards to the limit placed upon the numbers of state values that
unstable_effectOn
can track for TypeScript users. As the underlyingStateResolvers
type is shared amongcomputed
andunstable_effectOn
this change increases the number of supported state resolvers from 6 to 15. One might argue that anything over 10 is bad design, but there may still be limited use-cases foreffectOn
especially.It should be noted, however, that if someone does try to exceed this limit, TypeScript simply won't compile without a
@ts-ignore
. There is an alternative approach which supportsN
number of resolvers, but which loses inference for theNth + 1
computed func arg or change array member (forcomputed
andeffectOn
, respectively). You can find that change (built upon this change) here. If this is preferred, I can merge these changes and squash them into a single commit.StateResolvers
union to support an array up to 15StateResolver
scomputed
function'scompFunc
conditional to allow the maximum number of state resolversunstable_EffectOn
'sDependencies
type to allow the maximum number of state resolvers