Skip to content

refactor(*): centralize NonUndefinedGuard type definition #9187

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

Merged
merged 1 commit into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
DefaultError,
InfiniteData,
InitialDataFunction,
NonUndefinedGuard,
OmitKeyof,
QueryKey,
SkipToken,
Expand Down Expand Up @@ -61,8 +62,6 @@ export type UnusedSkipTokenInfiniteOptions<
>
}

type NonUndefinedGuard<T> = T extends undefined ? never : T

export type DefinedInitialDataInfiniteOptions<
TQueryFnData,
TError = DefaultError,
Expand Down
3 changes: 1 addition & 2 deletions packages/angular-query-experimental/src/query-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
DataTag,
DefaultError,
InitialDataFunction,
NonUndefinedGuard,
OmitKeyof,
QueryFunction,
QueryKey,
Expand Down Expand Up @@ -36,8 +37,6 @@ export type UnusedSkipTokenOptions<
>
}

type NonUndefinedGuard<T> = T extends undefined ? never : T

export type DefinedInitialDataOptions<
TQueryFnData = unknown,
TError = DefaultError,
Expand Down
2 changes: 2 additions & 0 deletions packages/query-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import type { QueryFilters, QueryTypeFilter, SkipToken } from './utils'
import type { QueryCache } from './queryCache'
import type { MutationCache } from './mutationCache'

export type NonUndefinedGuard<T> = T extends undefined ? never : T

export type DistributiveOmit<
TObject,
TKey extends keyof TObject,
Expand Down
3 changes: 1 addition & 2 deletions packages/react-query/src/infiniteQueryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
DefaultError,
InfiniteData,
InitialDataFunction,
NonUndefinedGuard,
OmitKeyof,
QueryKey,
SkipToken,
Expand Down Expand Up @@ -61,8 +62,6 @@ export type UnusedSkipTokenInfiniteOptions<
>
}

type NonUndefinedGuard<T> = T extends undefined ? never : T

export type DefinedInitialDataInfiniteOptions<
TQueryFnData,
TError = DefaultError,
Expand Down
3 changes: 1 addition & 2 deletions packages/react-query/src/queryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
DataTag,
DefaultError,
InitialDataFunction,
NonUndefinedGuard,
OmitKeyof,
QueryFunction,
QueryKey,
Expand Down Expand Up @@ -36,8 +37,6 @@ export type UnusedSkipTokenOptions<
>
}

type NonUndefinedGuard<T> = T extends undefined ? never : T

export type DefinedInitialDataOptions<
TQueryFnData = unknown,
TError = DefaultError,
Expand Down
3 changes: 1 addition & 2 deletions packages/solid-query/src/infiniteQueryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
DataTag,
DefaultError,
InfiniteData,
NonUndefinedGuard,
QueryKey,
} from '@tanstack/query-core'
import type { SolidInfiniteQueryOptions } from './types'
Expand All @@ -26,8 +27,6 @@ export type UndefinedInitialDataInfiniteOptions<
}
>

type NonUndefinedGuard<T> = T extends undefined ? never : T

export type DefinedInitialDataInfiniteOptions<
TQueryFnData,
TError = DefaultError,
Expand Down
3 changes: 1 addition & 2 deletions packages/svelte-query/src/queryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
DataTag,
DefaultError,
InitialDataFunction,
NonUndefinedGuard,
QueryKey,
} from '@tanstack/query-core'
import type { CreateQueryOptions } from './types.js'
Expand All @@ -15,8 +16,6 @@ export type UndefinedInitialDataOptions<
initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>
}

type NonUndefinedGuard<T> = T extends undefined ? never : T

export type DefinedInitialDataOptions<
TQueryFnData = unknown,
TError = DefaultError,
Expand Down
3 changes: 1 addition & 2 deletions packages/vue-query/src/infiniteQueryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {
DataTag,
DefaultError,
InfiniteData,
NonUndefinedGuard,
QueryKey,
} from '@tanstack/query-core'
import type { UseInfiniteQueryOptions } from './useInfiniteQuery'
Expand All @@ -23,8 +24,6 @@ export type UndefinedInitialDataInfiniteOptions<
initialData?: undefined
}

type NonUndefinedGuard<T> = T extends undefined ? never : T

export type DefinedInitialDataInfiniteOptions<
TQueryFnData,
TError = DefaultError,
Expand Down
3 changes: 1 addition & 2 deletions packages/vue-query/src/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
DefaultError,
DefinedQueryObserverResult,
InitialDataFunction,
NonUndefinedGuard,
QueryKey,
QueryObserverOptions,
} from '@tanstack/query-core'
Expand All @@ -16,8 +17,6 @@ import type {
} from './types'
import type { QueryClient } from './queryClient'

type NonUndefinedGuard<T> = T extends undefined ? never : T

export type UseQueryOptions<
TQueryFnData = unknown,
TError = DefaultError,
Expand Down
Loading