Skip to content

Commit 7b5bb5d

Browse files
ci: apply automated fixes
1 parent ba016fa commit 7b5bb5d

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

packages/react-query/src/__tests__/useQuery.test-d.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,8 @@ describe('initialData', () => {
128128
})
129129

130130
describe('TData type inference', () => {
131-
132131
it('no inference of TData from return annotations', () => {
133-
134-
const _testFn = (): UseQueryResult<string, unknown> => {
132+
const _testFn = (): UseQueryResult<string, unknown> => {
135133
// @ts-expect-error expect number to be un-assignable to string
136134
return useQuery({
137135
queryKey: [],
@@ -147,39 +145,37 @@ describe('initialData', () => {
147145
})
148146

149147
it('correct or superset type annotations produce no type errors', () => {
150-
151-
const _testFn = (): UseQueryResult<number | string, unknown> => {
148+
const _testFn = (): UseQueryResult<number | string, unknown> => {
152149
return useQuery({
153150
queryKey: [],
154151
queryFn: () => 5,
155152
})
156153
}
157154

158-
expectTypeOf(_testFn()["data"]).toEqualTypeOf<string | number>()
155+
expectTypeOf(_testFn()['data']).toEqualTypeOf<string | number>()
159156

160157
const _val: UseQueryResult<string | number, unknown> = useQuery({
161158
queryKey: [],
162159
queryFn: () => 5,
163160
})
164161

165-
expectTypeOf(_val["data"]).toEqualTypeOf<string | number | undefined>()
162+
expectTypeOf(_val['data']).toEqualTypeOf<string | number | undefined>()
166163
})
167164

168165
it('usage of select function still changes generic inference', () => {
169-
170166
const result = useQuery({
171167
queryKey: [],
172168
queryFn: () => 5,
173-
select: () => "foo"
169+
select: () => 'foo',
174170
})
175171

176-
expectTypeOf(result["data"]).toEqualTypeOf<string | undefined>()
172+
expectTypeOf(result['data']).toEqualTypeOf<string | undefined>()
177173

178174
const _result2 = useQuery<number, unknown, string, unknown[]>({
179175
queryKey: [],
180176
queryFn: () => 5,
181177
// @ts-expect-error select fn differs from generic (when provided), so correctly type errors)
182-
select: () => 5
178+
select: () => 5,
183179
})
184180
})
185181
})

packages/react-query/src/useQuery.ts

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

0 commit comments

Comments
 (0)