diff --git a/plugins/typescript/src/generators/generateReactQueryComponents.test.ts b/plugins/typescript/src/generators/generateReactQueryComponents.test.ts index dd5b9ebb..ebabd1da 100644 --- a/plugins/typescript/src/generators/generateReactQueryComponents.test.ts +++ b/plugins/typescript/src/generators/generateReactQueryComponents.test.ts @@ -109,7 +109,7 @@ describe("generateReactQueryComponents", () => { /** * Get all the pets */ - export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { + export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { ...options, ...queryOptions }); }; @@ -231,7 +231,7 @@ describe("generateReactQueryComponents", () => { /** * Get all the pets */ - export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { + export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { ...options, ...queryOptions }); }; @@ -357,7 +357,7 @@ describe("generateReactQueryComponents", () => { /** * Get all the pets */ - export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { + export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { ...options, ...queryOptions }); }; @@ -454,7 +454,7 @@ describe("generateReactQueryComponents", () => { /** * Get all the pets */ - export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { + export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { ...options, ...queryOptions }); }; @@ -1162,7 +1162,7 @@ describe("generateReactQueryComponents", () => { /** * Get all the pets */ - export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { + export const useListPets = (variables: ListPetsVariables, options?: Omit, \\"queryKey\\" | \\"queryFn\\">) => { const { fetcherOptions, queryOptions, queryKeyFn } = usePetstoreContext(options); return reactQuery.useQuery(queryKeyFn({ path: \\"/pets\\", operationId: \\"listPets\\", variables }), () => fetchListPets({ ...fetcherOptions, ...variables }), { ...options, ...queryOptions }); }; diff --git a/plugins/typescript/src/generators/generateReactQueryComponents.ts b/plugins/typescript/src/generators/generateReactQueryComponents.ts index f73d0274..a59ebe0c 100644 --- a/plugins/typescript/src/generators/generateReactQueryComponents.ts +++ b/plugins/typescript/src/generators/generateReactQueryComponents.ts @@ -462,7 +462,7 @@ const createQueryHook = ({ undefined, f.createArrowFunction( undefined, - undefined, + [f.createTypeParameterDeclaration("TData", undefined, dataType)], [ f.createParameterDeclaration( undefined, @@ -527,7 +527,14 @@ const createQueryHook = ({ f.createIdentifier("reactQuery"), f.createIdentifier("useQuery") ), - [dataType, errorType, dataType], + [ + dataType, + errorType, + f.createTypeReferenceNode( + f.createIdentifier("TData"), + [] + ), + ], [ f.createCallExpression( f.createIdentifier("queryKeyFn"), @@ -608,7 +615,11 @@ const createUseQueryOptionsType = ( f.createIdentifier("reactQuery"), f.createIdentifier("UseQueryOptions") ), - [dataType, errorType, dataType] + [ + dataType, + errorType, + f.createTypeReferenceNode(f.createIdentifier("TData"), []), + ] ), f.createUnionTypeNode([ f.createLiteralTypeNode(f.createStringLiteral("queryKey")),