refactor(solid-query): replace Accessor<T> wth FunctionedParams<T> #8535
+12
−11
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.
I'd like to open a discussion about replacing
FunctionedParams<T>
with solid-js's built inAccessor<T>
in our codebase, which would reduce cognitive overhead for developers.First, I just wanted to acknowledge that I see the argument for keeping
FunctionedParams<T>
—it's used in a specific context thatAccessor<T>
is not necessarily used for, and there is a specificity communicated in its name. We know that any place FunctionedParams is mentioned typically wraps some sort of option or configuration.That being said, I thnk the contextual value of name "FunctionedParams" over "Accessor" is the only reason this utility type should exist. SolidJS already provides
Accessor<T>
type with the exact same type signature. Typescript is a structurally typed language, and so there are fewer benefits of using two types with identical type signatures that are only different in name. Having an identicalFunctionedParams<T>
doesn't add any extra type clarity.The separate naming isn't just neutral, but I believe "FunctionedParams" would be more confusing than just using "Accessor" for most developers.
Cognitive overload/another unnecessary abstraction to memorize: Developer experience when jumping to definition, the name is unfamiliar and requires them to jump to the definition of
FunctionedParams<T> = () => T
. It's unnecessary complexity without providing additional clarity, and another repo-specific concept they need to memorize.The name is misleading. On first glance, the term
FunctionedParams
might suggest parameters being transformed, which isn't what's happening—we're simply accessing values through functions.Name is redundant.
FunctionedParams
typically used in contexts where it's already clear we're dealing with parameters (e.g., in function signatures), making the "Params" suffix unnecessary.With Accessor, we can use a type that consuming developers are already familiar with and match established patterns in SolidJS, reducing cognitive overhead for developers.
Are there specific cases where
FunctionedParams
provides better clarity? I think we should either:FunctionedParams<T>
withAccessor<T>
type FunctionedParams<T> = Accessor<T>