Skip to content

Commit 688bc2f

Browse files
committed
fix(react-query): fix lint ci error
1 parent dabc800 commit 688bc2f

File tree

1 file changed

+60
-23
lines changed
  • packages/openapi-react-query/src

1 file changed

+60
-23
lines changed

packages/openapi-react-query/src/index.ts

+60-23
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,34 @@ export type UseInfiniteQueryMethod<Paths extends Record<string, Record<HttpMetho
9696
method: Method,
9797
url: Path,
9898
...[init, options, queryClient]: RequiredKeysOf<Init> extends never
99-
? [InitWithUnknowns<Init>?, Omit<UseInfiniteQueryOptions<Response["data"], Response["error"], Response["data"], number, QueryKey<Paths, Method, Path>>, "queryKey" | "queryFn">?, QueryClient?]
100-
: [InitWithUnknowns<Init>, Omit<UseInfiniteQueryOptions<Response["data"], Response["error"], Response["data"], number, QueryKey<Paths, Method, Path>>, "queryKey" | "queryFn">?, QueryClient?]
99+
? [
100+
InitWithUnknowns<Init>?,
101+
Omit<
102+
UseInfiniteQueryOptions<
103+
Response["data"],
104+
Response["error"],
105+
Response["data"],
106+
number,
107+
QueryKey<Paths, Method, Path>
108+
>,
109+
"queryKey" | "queryFn"
110+
>?,
111+
QueryClient?,
112+
]
113+
: [
114+
InitWithUnknowns<Init>,
115+
Omit<
116+
UseInfiniteQueryOptions<
117+
Response["data"],
118+
Response["error"],
119+
Response["data"],
120+
number,
121+
QueryKey<Paths, Method, Path>
122+
>,
123+
"queryKey" | "queryFn"
124+
>?,
125+
QueryClient?,
126+
]
101127
) => UseInfiniteQueryResult<Response["data"], Response["error"]>;
102128

103129
export type UseMutationMethod<Paths extends Record<string, Record<HttpMethod, {}>>, Media extends MediaType> = <
@@ -145,22 +171,30 @@ export default function createClient<Paths extends {}, Media extends MediaType =
145171
...options,
146172
});
147173

148-
149174
const infiniteQueryOptions = <
150-
Method extends HttpMethod,
151-
Path extends PathsWithMethod<Paths, Method>,
152-
Init extends MaybeOptionalInit<Paths[Path], Method & keyof Paths[Path]>,
153-
Response extends Required<FetchResponse<any, Init, Media>>,
154-
>(
155-
method: Method,
156-
path: Path,
157-
init?: InitWithUnknowns<Init>,
158-
options?: Omit<UseInfiniteQueryOptions<Response["data"], Response["error"], Response["data"], number, QueryKey<Paths, Method, Path>>, "queryKey" | "queryFn">
159-
) => ({
160-
queryKey: [method, path, init] as const,
161-
queryFn,
162-
...options,
163-
});
175+
Method extends HttpMethod,
176+
Path extends PathsWithMethod<Paths, Method>,
177+
Init extends MaybeOptionalInit<Paths[Path], Method & keyof Paths[Path]>,
178+
Response extends Required<FetchResponse<any, Init, Media>>,
179+
>(
180+
method: Method,
181+
path: Path,
182+
init?: InitWithUnknowns<Init>,
183+
options?: Omit<
184+
UseInfiniteQueryOptions<
185+
Response["data"],
186+
Response["error"],
187+
Response["data"],
188+
number,
189+
QueryKey<Paths, Method, Path>
190+
>,
191+
"queryKey" | "queryFn"
192+
>,
193+
) => ({
194+
queryKey: [method, path, init] as const,
195+
queryFn,
196+
...options,
197+
});
164198

165199
return {
166200
queryOptions,
@@ -170,12 +204,15 @@ export default function createClient<Paths extends {}, Media extends MediaType =
170204
useSuspenseQuery(queryOptions(method, path, init as InitWithUnknowns<typeof init>, options), queryClient),
171205
useInfiniteQuery: (method, path, ...[init, options, queryClient]) => {
172206
const baseOptions = infiniteQueryOptions(method, path, init as InitWithUnknowns<typeof init>, options as any); // TODO: find a way to avoid as any
173-
return useInfiniteQuery({
174-
...baseOptions,
175-
initialPageParam: 0,
176-
getNextPageParam: (lastPage: any, allPages: any[], lastPageParam: number, allPageParams: number[]) =>
177-
options?.getNextPageParam?.(lastPage, allPages, lastPageParam, allPageParams) ?? allPages.length,
178-
} as any, queryClient);
207+
return useInfiniteQuery(
208+
{
209+
...baseOptions,
210+
initialPageParam: 0,
211+
getNextPageParam: (lastPage: any, allPages: any[], lastPageParam: number, allPageParams: number[]) =>
212+
options?.getNextPageParam?.(lastPage, allPages, lastPageParam, allPageParams) ?? allPages.length,
213+
} as any,
214+
queryClient,
215+
);
179216
},
180217
useMutation: (method, path, options, queryClient) =>
181218
useMutation(

0 commit comments

Comments
 (0)