-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
remove overloads #2918
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
Comments
I will try to tackle this one! Never done a codemod, so depends what all that would entail. |
Thanks @babycourageous. FYI, I've updated the description, it now also contains the intended api change for |
Just started to kick this one off over the weekend. Before I go too far down the refactor rabbit hole, just want to start confirming a few with ya! Would you like similar/related functions to follow the same single options object/no overloads api. For example, ie prefetchQuery<
TQueryFnData = unknown,
TError = unknown,
TData = TQueryFnData,
TQueryKey extends QueryKey = QueryKey
>(
options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>
): Promise<void> {
return this.fetchQuery(options).then(noop).catch(noop)
} Now that interface QueryDefaults {
// queryKey: QueryKey <-- REMOVE since it is required as part of QueryOptions
defaultOptions: QueryOptions<any, any, any>
}
setQueryDefaults(
options: QueryObserverOptions<any, any, any, any>
): void {
const result = this.queryDefaults.find(
x => hashQueryKey(options.queryKey) === hashQueryKey(x.defaultOptions.queryKey)
)
if (result) {
result.defaultOptions = options
} else {
this.queryDefaults.push({
defaultOptions: options,
})
}
}
getQueryDefaults(
queryKey?: QueryKey
): QueryObserverOptions<any, any, any, any, any> | undefined {
return queryKey
? this.queryDefaults.find(x => partialMatchKey(queryKey, x.defaultOptions.queryKey))
?.defaultOptions
: undefined
} |
I've outline all the changes that I think should happen in this issue: please have a look at the description and expand the details for examples (some of them) and syntax changes. judging from that list:
if its easier conceptually, let's split the "remove overloads" part and the "queryKey must be required part". In the end, queryKey is not going to be required everywhere. On filters for example, it won't be. I also don't understand the getQueryDefaults / setQueryDefaults part. Those functions look fine and I don't see why
hope that makes sense. If not, I'm happy to chat synchronously on a call about this :) |
Awesome, thanks! Totally agree on your buckets. Seeing it typed out I think I even had that Just let me know if you prefer splitting this into two PRs - overloads and required |
Since we likely can’t work in parallel, splitting is not needed unless doing it at once would make it harder for you :) |
Altogether is AOK (and how i started heheh) |
We’re not going forward with this as of now due to this design limitation in TypeScript: microsoft/TypeScript#43371 (comment) |
Proposed solution
Also, provide a codemod to help with the transition
queryKey
should then also be required in the optionsWe also want to change the useQueries api (see #2923) for the full discussion. I'm moving the api change here because it should be part of the codemod, too:
The text was updated successfully, but these errors were encountered: