Skip to content

Commit 1217ba8

Browse files
committed
fix: reorder setQueryData params to allow optional options at end
Move options to the last parameter position in both setQueryData and useSetQueryData so it can be properly optional when the operation has no required params. The previous approach placed options? in the middle with a required param after it, which is invalid TypeScript. Also removes duplicate isRequiredOptions declarations introduced in a prior commit.
1 parent 0ebb851 commit 1217ba8

8 files changed

Lines changed: 94 additions & 102 deletions

File tree

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/setQueryData/@tanstack/react-query.gen.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const serviceWithEmptyTagOptions = (options?: Options<ServiceWithEmptyTag
5454
queryKey: serviceWithEmptyTagQueryKey(options)
5555
});
5656

57-
export const serviceWithEmptyTagSetQueryData = (queryClient: QueryClient, options?: Options<ServiceWithEmptyTagData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(serviceWithEmptyTagOptions(options).queryKey, updater);
57+
export const serviceWithEmptyTagSetQueryData = (queryClient: QueryClient, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined), options?: Options<ServiceWithEmptyTagData>) => queryClient.setQueryData(serviceWithEmptyTagOptions(options).queryKey, updater);
5858

5959
export const patchApiVbyApiVersionNoTagMutation = (options?: Partial<Options<PatchApiVbyApiVersionNoTagData>>): UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> => {
6060
const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> = {
@@ -113,7 +113,7 @@ export const getCallWithoutParametersAndResponseOptions = (options?: Options<Get
113113
queryKey: getCallWithoutParametersAndResponseQueryKey(options)
114114
});
115115

116-
export const getCallWithoutParametersAndResponseSetQueryData = (queryClient: QueryClient, options?: Options<GetCallWithoutParametersAndResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(getCallWithoutParametersAndResponseOptions(options).queryKey, updater);
116+
export const getCallWithoutParametersAndResponseSetQueryData = (queryClient: QueryClient, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined), options?: Options<GetCallWithoutParametersAndResponseData>) => queryClient.setQueryData(getCallWithoutParametersAndResponseOptions(options).queryKey, updater);
117117

118118
export const patchCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PatchCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> => {
119119
const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> = {
@@ -214,7 +214,7 @@ export const callWithDefaultParametersOptions = (options: Options<CallWithDefaul
214214
queryKey: callWithDefaultParametersQueryKey(options)
215215
});
216216

217-
export const callWithDefaultParametersSetQueryData = (queryClient: QueryClient, options: Options<CallWithDefaultParametersData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(callWithDefaultParametersOptions(options).queryKey, updater);
217+
export const callWithDefaultParametersSetQueryData = (queryClient: QueryClient, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined), options: Options<CallWithDefaultParametersData>) => queryClient.setQueryData(callWithDefaultParametersOptions(options).queryKey, updater);
218218

219219
export const callWithDefaultOptionalParametersMutation = (options?: Partial<Options<CallWithDefaultOptionalParametersData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>> => {
220220
const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithDefaultOptionalParametersData>> = {
@@ -273,7 +273,7 @@ export const duplicateName2Options = (options?: Options<DuplicateName2Data>) =>
273273
queryKey: duplicateName2QueryKey(options)
274274
});
275275

276-
export const duplicateName2SetQueryData = (queryClient: QueryClient, options?: Options<DuplicateName2Data>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(duplicateName2Options(options).queryKey, updater);
276+
export const duplicateName2SetQueryData = (queryClient: QueryClient, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined), options?: Options<DuplicateName2Data>) => queryClient.setQueryData(duplicateName2Options(options).queryKey, updater);
277277

278278
export const duplicateName3Mutation = (options?: Partial<Options<DuplicateName3Data>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> => {
279279
const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> = {
@@ -318,7 +318,7 @@ export const callWithNoContentResponseOptions = (options?: Options<CallWithNoCon
318318
queryKey: callWithNoContentResponseQueryKey(options)
319319
});
320320

321-
export const callWithNoContentResponseSetQueryData = (queryClient: QueryClient, options?: Options<CallWithNoContentResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(callWithNoContentResponseOptions(options).queryKey, updater);
321+
export const callWithNoContentResponseSetQueryData = (queryClient: QueryClient, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined), options?: Options<CallWithNoContentResponseData>) => queryClient.setQueryData(callWithNoContentResponseOptions(options).queryKey, updater);
322322

323323
export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options);
324324

@@ -335,7 +335,7 @@ export const callWithResponseAndNoContentResponseOptions = (options?: Options<Ca
335335
queryKey: callWithResponseAndNoContentResponseQueryKey(options)
336336
});
337337

338-
export const callWithResponseAndNoContentResponseSetQueryData = (queryClient: QueryClient, options?: Options<CallWithResponseAndNoContentResponseData>, updater: CallWithResponseAndNoContentResponseResponse | undefined | ((old: CallWithResponseAndNoContentResponseResponse | undefined) => CallWithResponseAndNoContentResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseAndNoContentResponseOptions(options).queryKey, updater);
338+
export const callWithResponseAndNoContentResponseSetQueryData = (queryClient: QueryClient, updater: CallWithResponseAndNoContentResponseResponse | undefined | ((old: CallWithResponseAndNoContentResponseResponse | undefined) => CallWithResponseAndNoContentResponseResponse | undefined), options?: Options<CallWithResponseAndNoContentResponseData>) => queryClient.setQueryData(callWithResponseAndNoContentResponseOptions(options).queryKey, updater);
339339

340340
export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options);
341341

@@ -352,7 +352,7 @@ export const dummyAOptions = (options?: Options<DummyAData>) => queryOptions<unk
352352
queryKey: dummyAQueryKey(options)
353353
});
354354

355-
export const dummyASetQueryData = (queryClient: QueryClient, options?: Options<DummyAData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyAOptions(options).queryKey, updater);
355+
export const dummyASetQueryData = (queryClient: QueryClient, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined), options?: Options<DummyAData>) => queryClient.setQueryData(dummyAOptions(options).queryKey, updater);
356356

357357
export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options);
358358

@@ -369,7 +369,7 @@ export const dummyBOptions = (options?: Options<DummyBData>) => queryOptions<unk
369369
queryKey: dummyBQueryKey(options)
370370
});
371371

372-
export const dummyBSetQueryData = (queryClient: QueryClient, options?: Options<DummyBData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyBOptions(options).queryKey, updater);
372+
export const dummyBSetQueryData = (queryClient: QueryClient, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined), options?: Options<DummyBData>) => queryClient.setQueryData(dummyBOptions(options).queryKey, updater);
373373

374374
export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options);
375375

@@ -386,7 +386,7 @@ export const callWithResponseOptions = (options?: Options<CallWithResponseData>)
386386
queryKey: callWithResponseQueryKey(options)
387387
});
388388

389-
export const callWithResponseSetQueryData = (queryClient: QueryClient, options?: Options<CallWithResponseData>, updater: CallWithResponseResponse | undefined | ((old: CallWithResponseResponse | undefined) => CallWithResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseOptions(options).queryKey, updater);
389+
export const callWithResponseSetQueryData = (queryClient: QueryClient, updater: CallWithResponseResponse | undefined | ((old: CallWithResponseResponse | undefined) => CallWithResponseResponse | undefined), options?: Options<CallWithResponseData>) => queryClient.setQueryData(callWithResponseOptions(options).queryKey, updater);
390390

391391
export const callWithDuplicateResponsesMutation = (options?: Partial<Options<CallWithDuplicateResponsesData>>): UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> => {
392392
const mutationOptions: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> = {
@@ -431,7 +431,7 @@ export const collectionFormatOptions = (options: Options<CollectionFormatData>)
431431
queryKey: collectionFormatQueryKey(options)
432432
});
433433

434-
export const collectionFormatSetQueryData = (queryClient: QueryClient, options: Options<CollectionFormatData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(collectionFormatOptions(options).queryKey, updater);
434+
export const collectionFormatSetQueryData = (queryClient: QueryClient, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined), options: Options<CollectionFormatData>) => queryClient.setQueryData(collectionFormatOptions(options).queryKey, updater);
435435

436436
export const typesQueryKey = (options: Options<TypesData>) => createQueryKey('types', options);
437437

@@ -448,7 +448,7 @@ export const typesOptions = (options: Options<TypesData>) => queryOptions<TypesR
448448
queryKey: typesQueryKey(options)
449449
});
450450

451-
export const typesSetQueryData = (queryClient: QueryClient, options: Options<TypesData>, updater: TypesResponse | undefined | ((old: TypesResponse | undefined) => TypesResponse | undefined)) => queryClient.setQueryData(typesOptions(options).queryKey, updater);
451+
export const typesSetQueryData = (queryClient: QueryClient, updater: TypesResponse | undefined | ((old: TypesResponse | undefined) => TypesResponse | undefined), options: Options<TypesData>) => queryClient.setQueryData(typesOptions(options).queryKey, updater);
452452

453453
export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => createQueryKey('complexTypes', options);
454454

@@ -465,7 +465,7 @@ export const complexTypesOptions = (options: Options<ComplexTypesData>) => query
465465
queryKey: complexTypesQueryKey(options)
466466
});
467467

468-
export const complexTypesSetQueryData = (queryClient: QueryClient, options: Options<ComplexTypesData>, updater: ComplexTypesResponse | undefined | ((old: ComplexTypesResponse | undefined) => ComplexTypesResponse | undefined)) => queryClient.setQueryData(complexTypesOptions(options).queryKey, updater);
468+
export const complexTypesSetQueryData = (queryClient: QueryClient, updater: ComplexTypesResponse | undefined | ((old: ComplexTypesResponse | undefined) => ComplexTypesResponse | undefined), options: Options<ComplexTypesData>) => queryClient.setQueryData(complexTypesOptions(options).queryKey, updater);
469469

470470
export const callWithResultFromHeaderMutation = (options?: Partial<Options<CallWithResultFromHeaderData>>): UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>> => {
471471
const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<CallWithResultFromHeaderData>> = {

0 commit comments

Comments
 (0)