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

refactor(svelte-query): rename FunctionedParams<T> to Accessor<T> for improved semantics and consistency, use in function return types #8534

Open
wants to merge 2 commits into
base: svelte-5-adapter
Choose a base branch
from

Conversation

braden-w
Copy link

@braden-w braden-w commented Jan 14, 2025

This change renames FunctionedParams<T> to Accessor<T> to improve code clarity and align with established patterns in the ecosystem. The change brings several key benefits:

  1. Alignment with Established Standards: The name Accessor<T> aligns with established patterns, particularly SolidJS's Accessor utility type.

For example, you can already see this same pattern is used in solid-query's createQuery.ts, createQueries.ts, isRestoring.ts

  1. Semantic Clarity: The term "Accessor" better describes the type's purpose - a function that provides access to a value. The previous name FunctionedParams was ambiguous and could be misinterpreted as parameters that have been "functioned" or transformed.

  2. Removal of Redundancy: The word "Params" in FunctionedParams<T> was redundant since this type is already used in parameter positions. For example:

export function createQuery<T>(
  options: Accessor<CreateQueryOptions<T>>,  // Clearer than FunctionedParams
  queryClient?: QueryClient
)
  1. Broader Type Utility: The Accessor type can be consistently reused to type function return types across the codebase, particularly in utility hooks like useIsFetching, useIsMutating, useIsRestoring, and context functions. This creates a unified type pattern for functions that provide access to reactive values.

This change is more in line with solid.js's Accessor utility type and improves readability. The "Params" in FunctionedParams<T> is misleading since FunctionedParams<T> is already called invoked in the parameters of a function anyway
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant