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

type(query-core): add Override #7916

Merged
merged 26 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4f3a5f4
type(react-query, svelte-query): remove unnecessary Override type
manudeli Aug 18, 2024
372fc8f
Merge branch 'main' into type/Override/remove
manudeli Aug 19, 2024
ff082cd
Merge branch 'main' into type/Override/remove
manudeli Aug 19, 2024
7f9fad9
Merge branch 'main' into type/Override/remove
manudeli Aug 19, 2024
44c0c07
Merge branch 'main' into type/Override/remove
manudeli Aug 20, 2024
3bca6c3
Merge branch 'main' into type/Override/remove
manudeli Aug 21, 2024
434f856
Merge branch 'main' into type/Override/remove
manudeli Aug 21, 2024
efec311
feat(query-core): add Override
manudeli Aug 22, 2024
ea4ac2e
Merge branch 'main' into type/Override/remove
manudeli Aug 22, 2024
007b87c
chore: update
manudeli Aug 23, 2024
32bc3fe
chore: update
manudeli Aug 23, 2024
37ff956
Merge branch 'main' into type/Override/remove
manudeli Aug 24, 2024
53c5d98
Merge branch 'main' into type/Override/remove
manudeli Aug 26, 2024
f414961
Merge branch 'main' into type/Override/remove
manudeli Aug 26, 2024
082f31d
Merge branch 'main' into type/Override/remove
manudeli Aug 29, 2024
98cb2bb
Merge branch 'main' into type/Override/remove
manudeli Aug 30, 2024
270cf5c
Merge branch 'main' into type/Override/remove
manudeli Aug 30, 2024
5274edc
Merge branch 'main' into type/Override/remove
manudeli Aug 31, 2024
ebd756a
Merge branch 'main' into type/Override/remove
manudeli Sep 3, 2024
6937690
Merge branch 'main' into type/Override/remove
manudeli Sep 4, 2024
779df2e
Merge branch 'main' into type/Override/remove
manudeli Sep 4, 2024
c0e0d22
Merge branch 'main' into type/Override/remove
manudeli Sep 4, 2024
9e25a1d
Merge branch 'main' into type/Override/remove
manudeli Sep 6, 2024
9dada17
Merge branch 'main' into type/Override/remove
manudeli Sep 6, 2024
59e7b25
Merge branch 'main' into type/Override/remove
TkDodo Sep 8, 2024
967fd48
Merge branch 'main' into type/Override/remove
TkDodo Sep 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/angular-query-experimental/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
MutationObserverOptions,
MutationObserverResult,
OmitKeyof,
Override,
QueryKey,
QueryObserverOptions,
QueryObserverResult,
Expand Down Expand Up @@ -304,12 +305,6 @@ export type CreateMutationResult<
> = BaseMutationNarrowing<TData, TError, TVariables, TContext> &
MapToSignals<OmitKeyof<TState, keyof BaseMutationNarrowing, 'safely'>>

type Override<TTargetA, TTargetB> = {
[AKey in keyof TTargetA]: AKey extends keyof TTargetB
? TTargetB[AKey]
: TTargetA[AKey]
}

/**
* @public
*/
Expand Down
6 changes: 6 additions & 0 deletions packages/query-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export type OmitKeyof<
TStrictly extends 'strictly' | 'safely' = 'strictly',
> = Omit<TObject, TKey>

export type Override<TTargetA, TTargetB> = {
[AKey in keyof TTargetA]: AKey extends keyof TTargetB
? TTargetB[AKey]
: TTargetA[AKey]
}
Comment on lines +23 to +27
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extract useful Override type from each framework packages to @tanstack/query-core to share it


export type NoInfer<T> = [T][T extends any ? 0 : never]

export interface Register {
Expand Down
11 changes: 4 additions & 7 deletions packages/react-query/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
MutationObserverOptions,
MutationObserverResult,
OmitKeyof,
Override,
QueryKey,
QueryObserverOptions,
QueryObserverResult,
Expand Down Expand Up @@ -159,17 +160,13 @@ export type UseBaseMutationResult<
> = Override<
MutationObserverResult<TData, TError, TVariables, TContext>,
{ mutate: UseMutateFunction<TData, TError, TVariables, TContext> }
> & { mutateAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext> }
> & {
mutateAsync: UseMutateAsyncFunction<TData, TError, TVariables, TContext>
}

export type UseMutationResult<
TData = unknown,
TError = DefaultError,
TVariables = unknown,
TContext = unknown,
> = UseBaseMutationResult<TData, TError, TVariables, TContext>

type Override<TTargetA, TTargetB> = {
[AKey in keyof TTargetA]: AKey extends keyof TTargetB
? TTargetB[AKey]
: TTargetA[AKey]
}
7 changes: 1 addition & 6 deletions packages/solid-query/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
MutationObserverOptions,
MutationObserverResult,
OmitKeyof,
Override,
QueryKey,
QueryObserverResult,
} from '@tanstack/query-core'
Expand Down Expand Up @@ -200,9 +201,3 @@ export type CreateMutationResult<
TVariables = unknown,
TContext = unknown,
> = CreateBaseMutationResult<TData, TError, TVariables, TContext>

type Override<TTargetA, TTargetB> = {
[AKey in keyof TTargetA]: AKey extends keyof TTargetB
? TTargetB[AKey]
: TTargetA[AKey]
}
7 changes: 1 addition & 6 deletions packages/svelte-query/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
MutationObserverResult,
MutationState,
OmitKeyof,
Override,
QueryKey,
QueryObserverOptions,
QueryObserverResult,
Expand Down Expand Up @@ -130,12 +131,6 @@ export type CreateMutationResult<
TContext = unknown,
> = Readable<CreateBaseMutationResult<TData, TError, TVariables, TContext>>

type Override<TTargetA, TTargetB> = {
[AKey in keyof TTargetA]: AKey extends keyof TTargetB
? TTargetB[AKey]
: TTargetA[AKey]
}

/** Options for useMutationState */
export type MutationStateOptions<TResult = MutationState> = {
filters?: MutationFilters
Expand Down
Loading