Skip to content

Commit

Permalink
refactor(query-core): move Override type to core (#7916)
Browse files Browse the repository at this point in the history
* type(react-query, svelte-query): remove unnecessary Override type

* feat(query-core): add Override

Co-authored-by: Lee HyunJae (whale) <[email protected]>

* chore: update

* chore: update

---------

Co-authored-by: Lee HyunJae (whale) <[email protected]>
Co-authored-by: Dominik Dorfmeister <[email protected]>
  • Loading branch information
3 people authored Sep 8, 2024
1 parent 4df469a commit f0c5022
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 24 deletions.
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 @@ -321,12 +322,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]
}

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

export interface Register {
Expand Down
7 changes: 1 addition & 6 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 @@ -167,9 +168,3 @@ export type UseMutationResult<
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

0 comments on commit f0c5022

Please sign in to comment.