kubb-labs / kubb

OpenAPI to TypeScript, React-Query, Zod, Zodios, Faker.js, MSW and Axios.
https://kubb.dev
MIT License
568 stars 40 forks source link

error TS2769: No overload matches this call. when using #1027

Open dmushkov opened 1 month ago

dmushkov commented 1 month ago

What version of kubb is running?

2.19.5

What platform is your computer?

Linux

What version of external packages are you using(@tanstack-query, MSW, React, Vue, ...)

swr

What steps can reproduce the bug?

kubb generate produces

export function useCreateContractor(params?: CreateContractor["queryParams"], options?: { mutation?: SWRMutationConfiguration<CreateContractor["response"], CreateContractor["error"]>; client?: CreateContractor["client"]["parameters"]; shouldFetch?: boolean; }): SWRMutationResponse<CreateContractor["response"], CreateContractor["error"]> { const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}; const url = /v1/contractors as const; return useSWRMutation<CreateContractor["response"], CreateContractor["error"], [ typeof url, typeof params ] | null>(shouldFetch ? [url, params] : null, async (_url) => { const res = await client<CreateContractor["data"], CreateContractor["error"]>({ method: "post", url, params, ...clientOptions }); return res; }, mutationOptions); }

but when I try to build I got .gen/hooks/useCreateContractor.ts:41:8 - error TS2769: No overload matches this call. Overload 1 of 3, '(key: ["/v1/contractors", CreateContractorQueryParams | undefined] | null, fetcher: (key: ["/v1/contractors", CreateContractorQueryParams | undefined], options: Readonly<...>) => FetcherResponse<...>, options?: SWRMutationConfiguration<...> | undefined): SWRMutationResponse<...>', gave the following error. Argument of type 'SWRMutationConfiguration<ResponseConfig, never> | undefined' is not assignable to parameter of type 'SWRMutationConfiguration<ResponseConfig, never, ["/v1/contractors", CreateContractorQueryParams | undefined] | null, never, ResponseConfig<...>> | undefined'. Type 'SWRMutationConfiguration<ResponseConfig, never>' is not assignable to type 'SWRMutationConfiguration<ResponseConfig, never, ["/v1/contractors", CreateContractorQueryParams | undefined] | null, never, ResponseConfig<...>>'. Types of property 'fetcher' are incompatible. Type '((key: string, options: Readonly<{ arg: any; }>) => FetcherResponse<ResponseConfig>) | ((key: ArgumentsTuple, options: Readonly<...>) => FetcherResponse<...>) | ((key: Record<...>, options: Readonly<...>) => FetcherResponse<...>) | ((key: string | ... 1 more ... | Record<...>, options: Readonly<...>...' is not assignable to type '((key: ["/v1/contractors", CreateContractorQueryParams | undefined], options: Readonly<{ arg: never; }>) => FetcherResponse<ResponseConfig>) | undefined'. Type '(key: string, options: Readonly<{ arg: any; }>) => FetcherResponse<ResponseConfig>' is not assignable to type '(key: ["/v1/contractors", CreateContractorQueryParams | undefined], options: Readonly<{ arg: never; }>) => FetcherResponse<ResponseConfig>'. Types of parameters 'key' and 'key' are incompatible. Type '["/v1/contractors", CreateContractorQueryParams | undefined]' is not assignable to type 'string'. Overload 2 of 3, '(key: ["/v1/contractors", CreateContractorQueryParams | undefined] | null, fetcher: (key: ["/v1/contractors", CreateContractorQueryParams | undefined], options: Readonly<...>) => FetcherResponse<...>, options?: (SWRMutationConfiguration<...> & { ...; }) | undefined): SWRMutationResponse<...>', gave the following error. Argument of type 'SWRMutationConfiguration<ResponseConfig, never> | undefined' is not assignable to parameter of type '(SWRMutationConfiguration<ResponseConfig, never, ["/v1/contractors", CreateContractorQueryParams | undefined] | null, never, ResponseConfig<...>> & { ...; }) | undefined'. Type 'SWRMutationConfiguration<ResponseConfig, never>' is not assignable to type 'SWRMutationConfiguration<ResponseConfig, never, ["/v1/contractors", CreateContractorQueryParams | undefined] | null, never, ResponseConfig<...>> & { ...; }'. Type 'SWRMutationConfiguration<ResponseConfig, never>' is not assignable to type 'SWRMutationConfiguration<ResponseConfig, never, ["/v1/contractors", CreateContractorQueryParams | undefined] | null, never, ResponseConfig<...>>'. Types of property 'fetcher' are incompatible. Type '((key: string, options: Readonly<{ arg: any; }>) => FetcherResponse<ResponseConfig>) | ((key: ArgumentsTuple, options: Readonly<...>) => FetcherResponse<...>) | ((key: Record<...>, options: Readonly<...>) => FetcherResponse<...>) | ((key: string | ... 1 more ... | Record<...>, options: Readonly<...>...' is not assignable to type '((key: ["/v1/contractors", CreateContractorQueryParams | undefined], options: Readonly<{ arg: never; }>) => FetcherResponse<ResponseConfig>) | undefined'. Type '(key: string, options: Readonly<{ arg: any; }>) => FetcherResponse<ResponseConfig>' is not assignable to type '(key: ["/v1/contractors", CreateContractorQueryParams | undefined], options: Readonly<{ arg: never; }>) => FetcherResponse<ResponseConfig>'. Types of parameters 'key' and 'key' are incompatible. Type '["/v1/contractors", CreateContractorQueryParams | undefined]' is not assignable to type 'string'. Overload 3 of 3, '(key: ["/v1/contractors", CreateContractorQueryParams | undefined] | null, fetcher: (key: ["/v1/contractors", CreateContractorQueryParams | undefined], options: Readonly<...>) => FetcherResponse<...>, options?: (SWRMutationConfiguration<...> & { ...; }) | undefined): SWRMutationResponse<...>', gave the following error. Argument of type 'SWRMutationConfiguration<ResponseConfig, never> | undefined' is not assignable to parameter of type '(SWRMutationConfiguration<ResponseConfig, never, ["/v1/contractors", CreateContractorQueryParams | undefined] | null, never, ResponseConfig<...>> & { ...; }) | undefined'. Type 'SWRMutationConfiguration<ResponseConfig, never>' is not assignable to type 'SWRMutationConfiguration<ResponseConfig, never, ["/v1/contractors", CreateContractorQueryParams | undefined] | null, never, ResponseConfig<...>> & { ...; }'. Type 'SWRMutationConfiguration<ResponseConfig, never>' is not assignable to type 'SWRMutationConfiguration<ResponseConfig, never, ["/v1/contractors", CreateContractorQueryParams | undefined] | null, never, ResponseConfig<...>>'.

41 }, mutationOptions);

How often does this bug happen?

None

What is the expected behavior?

No response

Swagger/OpenAPI file?

No response

Additional information

No response