Skip to content

Commit b70ff1f

Browse files
committed
refactor: remove unused infiniteQueryOptions type and fix test
- Remove InfiniteQueryOptionsFunction type (not used) - Fix mutation onSuccess test to match React Query callback signature
1 parent ec187d0 commit b70ff1f

File tree

2 files changed

+2
-56
lines changed

2 files changed

+2
-56
lines changed

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

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -97,59 +97,6 @@ export type MutationOptionsFunction<Paths extends Record<string, Record<HttpMeth
9797
}
9898
>;
9999

100-
// Helper type to infer TPageParam type
101-
type InferPageParamType<T> = T extends { initialPageParam: infer P } ? P : unknown;
102-
103-
export type InfiniteQueryOptionsFunction<
104-
Paths extends Record<string, Record<HttpMethod, {}>>,
105-
Media extends MediaType,
106-
> = <
107-
Method extends HttpMethod,
108-
Path extends PathsWithMethod<Paths, Method>,
109-
Init extends MaybeOptionalInit<Paths[Path], Method>,
110-
Response extends Required<FetchResponse<Paths[Path][Method], Init, Media>>,
111-
Options extends Omit<
112-
UseInfiniteQueryOptions<
113-
Response["data"],
114-
Response["error"],
115-
InferSelectReturnType<InfiniteData<Response["data"]>, Options["select"]>,
116-
QueryKey<Paths, Method, Path>,
117-
InferPageParamType<Options>
118-
>,
119-
"queryKey" | "queryFn"
120-
> & {
121-
pageParamName?: string;
122-
initialPageParam: InferPageParamType<Options>;
123-
},
124-
>(
125-
method: Method,
126-
path: Path,
127-
init: InitWithUnknowns<Init>,
128-
options: Options,
129-
) => NoInfer<
130-
Omit<
131-
UseInfiniteQueryOptions<
132-
Response["data"],
133-
Response["error"],
134-
InferSelectReturnType<InfiniteData<Response["data"]>, Options["select"]>,
135-
QueryKey<Paths, Method, Path>,
136-
InferPageParamType<Options>
137-
>,
138-
"queryFn"
139-
> & {
140-
queryFn: Exclude<
141-
UseInfiniteQueryOptions<
142-
Response["data"],
143-
Response["error"],
144-
InferSelectReturnType<InfiniteData<Response["data"]>, Options["select"]>,
145-
QueryKey<Paths, Method, Path>,
146-
InferPageParamType<Options>
147-
>["queryFn"],
148-
SkipToken | undefined
149-
>;
150-
}
151-
>;
152-
153100
export type UseQueryMethod<Paths extends Record<string, Record<HttpMethod, {}>>, Media extends MediaType> = <
154101
Method extends HttpMethod,
155102
Path extends PathsWithMethod<Paths, Method>,

packages/openapi-react-query/test/index.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,10 +820,9 @@ describe("client", () => {
820820
{ message: "Success" },
821821
{ body: { message: "Test", replied_at: 123456789 } },
822822
undefined,
823-
expect.objectContaining({
824-
mutationKey: ["put", "/comment"],
825-
}),
826823
);
824+
// Verify that mutationKey is part of the options object
825+
expect(options).toEqual(expect.objectContaining({ mutationKey: ["put", "/comment"] }));
827826
expect(onErrorSpy).not.toHaveBeenCalled();
828827
});
829828
});

0 commit comments

Comments
 (0)