Skip to content

Commit 7be4573

Browse files
refactor(query-core): drop NoInfer re-export, use built-in everywhere
Per @TkDodo's review: TypeScript's intrinsic NoInfer (TS ≥ 5.4) is the canonical type, and the package already requires TS ≥ 5.4. Removing the re-export sidesteps the self-shadowing issue entirely and avoids encouraging consumers to import a duplicate.
1 parent 9157c29 commit 7be4573

7 files changed

Lines changed: 3 additions & 22 deletions

File tree

.changeset/query-core-noinfer-builtin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
'@tanstack/vue-query': patch
44
---
55

6-
fix(query-core): use TypeScript's built-in `NoInfer` so `NoInfer<X[K]>` stays assignable to `X[K]` in generic contexts (fixes #9937)
6+
fix(query-core): drop the custom `NoInfer<T>` re-export and rely on TypeScript's built-in `NoInfer` (TS ≥ 5.4) so `NoInfer<X[K]>` stays assignable to `X[K]` in generic contexts (fixes #9937)

packages/preact-query/src/useQuery.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { QueryObserver } from '@tanstack/query-core'
2-
import type {
3-
DefaultError,
4-
NoInfer,
5-
QueryClient,
6-
QueryKey,
7-
} from '@tanstack/query-core'
2+
import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'
83

94
import type {
105
DefinedInitialDataOptions,

packages/query-core/src/noInfer.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/query-core/src/queryClient.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import type {
2929
MutationKey,
3030
MutationObserverOptions,
3131
MutationOptions,
32-
NoInfer,
3332
OmitKeyof,
3433
QueryClientConfig,
3534
QueryKey,

packages/query-core/src/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type { RetryDelayValue, RetryValue } from './retryer'
88
import type { QueryFilters, QueryTypeFilter, SkipToken } from './utils'
99
import type { QueryCache } from './queryCache'
1010
import type { MutationCache } from './mutationCache'
11-
import type { IntrinsicNoInfer } from './noInfer'
1211

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

@@ -35,8 +34,6 @@ export type Override<TTargetA, TTargetB> = {
3534
: TTargetA[AKey]
3635
}
3736

38-
export type NoInfer<T> = IntrinsicNoInfer<T>
39-
4037
export interface Register {
4138
// defaultError: Error
4239
// queryMeta: Record<string, unknown>

packages/react-query/src/useQuery.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
'use client'
22
import { QueryObserver } from '@tanstack/query-core'
33
import { useBaseQuery } from './useBaseQuery'
4-
import type {
5-
DefaultError,
6-
NoInfer,
7-
QueryClient,
8-
QueryKey,
9-
} from '@tanstack/query-core'
4+
import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'
105
import type {
116
DefinedUseQueryResult,
127
UseQueryOptions,

packages/vue-query/src/queryClient.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import type {
2121
MutationFilters,
2222
MutationKey,
2323
MutationObserverOptions,
24-
NoInfer,
2524
OmitKeyof,
2625
QueryFilters,
2726
QueryKey,

0 commit comments

Comments
 (0)