Skip to content

Commit 6e2e37e

Browse files
authored
fix(types): change the order of types so that correct type inference is picked for **Object syntax** (#1330)
* Change the order of types Change the order of types so that correct type inference is picked for Object sytax * change order of types * Update usePaginatedQuery.ts
1 parent 820b4ff commit 6e2e37e

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/react/useInfiniteQuery.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export interface UseInfiniteQueryObjectConfig<TResult, TError> {
1919

2020
// HOOK
2121

22+
// Object syntax
23+
export function useInfiniteQuery<TResult = unknown, TError = unknown>(
24+
config: UseInfiniteQueryObjectConfig<TResult, TError>
25+
): InfiniteQueryResult<TResult, TError>
26+
2227
// Parameter syntax with optional config
2328
export function useInfiniteQuery<TResult = unknown, TError = unknown>(
2429
queryKey: QueryKey,
@@ -42,11 +47,6 @@ export function useInfiniteQuery<TResult = unknown, TError = unknown>(
4247
queryConfig?: InfiniteQueryConfig<TResult, TError>
4348
): InfiniteQueryResult<TResult, TError>
4449

45-
// Object syntax
46-
export function useInfiniteQuery<TResult = unknown, TError = unknown>(
47-
config: UseInfiniteQueryObjectConfig<TResult, TError>
48-
): InfiniteQueryResult<TResult, TError>
49-
5050
// Implementation
5151
export function useInfiniteQuery<TResult, TError>(
5252
arg1: any,

src/react/usePaginatedQuery.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export interface UsePaginatedQueryObjectConfig<TResult, TError> {
2424

2525
// HOOK
2626

27+
// Object syntax
28+
export function usePaginatedQuery<TResult = unknown, TError = unknown>(
29+
config: UsePaginatedQueryObjectConfig<TResult, TError>
30+
): PaginatedQueryResult<TResult, TError>
31+
2732
// Parameter syntax with optional config
2833
export function usePaginatedQuery<TResult = unknown, TError = unknown>(
2934
queryKey: QueryKey,
@@ -47,11 +52,6 @@ export function usePaginatedQuery<TResult = unknown, TError = unknown>(
4752
queryConfig?: PaginatedQueryConfig<TResult, TError>
4853
): PaginatedQueryResult<TResult, TError>
4954

50-
// Object syntax
51-
export function usePaginatedQuery<TResult = unknown, TError = unknown>(
52-
config: UsePaginatedQueryObjectConfig<TResult, TError>
53-
): PaginatedQueryResult<TResult, TError>
54-
5555
// Implementation
5656
export function usePaginatedQuery<TResult, TError>(
5757
arg1: any,

src/react/useQuery.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export interface UseQueryObjectConfig<TResult, TError> {
1919

2020
// HOOK
2121

22+
// Object syntax
23+
export function useQuery<TResult = unknown, TError = unknown>(
24+
config: UseQueryObjectConfig<TResult, TError>
25+
): QueryResult<TResult, TError>
26+
2227
// Parameter syntax with optional config
2328
export function useQuery<TResult = unknown, TError = unknown>(
2429
queryKey: QueryKey,
@@ -38,10 +43,6 @@ export function useQuery<TResult = unknown, TError = unknown>(
3843
queryConfig?: QueryConfig<TResult, TError>
3944
): QueryResult<TResult, TError>
4045

41-
// Object syntax
42-
export function useQuery<TResult = unknown, TError = unknown>(
43-
config: UseQueryObjectConfig<TResult, TError>
44-
): QueryResult<TResult, TError>
4546

4647
// Implementation
4748
export function useQuery<TResult, TError>(

0 commit comments

Comments
 (0)