You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No overload matches this call.
Overload 1 of 3, '(petId: string, options?: { query?: (Partial<UseQueryOptions<petResponse, Promise<Error>, petResponse, QueryKey>> & Pick<...>) | undefined; fetch?: RequestInit | undefined; } | undefined): UseQueryResult<...> & { ...; }', gave the following error.
Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.
Overload 2 of 3, '(petId: string, options?: { query?: Partial<UseQueryOptions<petResponse, Promise<Error>, petResponse, QueryKey>> | undefined; fetch?: RequestInit | undefined; } | undefined): UseQueryResult<...> & { ...; }', gave the following error.
Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.ts(2769)
endpoints.ts(137, 17): The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible.
Generated overloads:
exportfunctionusePet<TData=Awaited<ReturnType<typeofpet>>,TError=Promise<Error>,>(// Should be string | undefined | nullpetId: string,options: {query: Partial<UseQueryOptions<Awaited<ReturnType<typeofpet>>,TError,TData>>&Pick<DefinedInitialDataOptions<Awaited<ReturnType<typeofpet>>,TError,TData>,"initialData">;fetch?: RequestInit;},): DefinedUseQueryResult<TData,TError>&{queryKey: QueryKey};exportfunctionusePet<TData=Awaited<ReturnType<typeofpet>>,TError=Promise<Error>,>(// Should be string | undefined | nullpetId: string,options?: {query?: Partial<UseQueryOptions<Awaited<ReturnType<typeofpet>>,TError,TData>>&Pick<UndefinedInitialDataOptions<Awaited<ReturnType<typeofpet>>,TError,TData>,"initialData">;fetch?: RequestInit;},): UseQueryResult<TData,TError>&{queryKey: QueryKey};exportfunctionusePet<TData=Awaited<ReturnType<typeofpet>>,TError=Promise<Error>,>(// Should be string | undefined | nullpetId: string,options?: {query?: Partial<UseQueryOptions<Awaited<ReturnType<typeofpet>>,TError,TData>>;fetch?: RequestInit;},): UseQueryResult<TData,TError>&{queryKey: QueryKey};/** * @summary Info for a specific pet */exportfunctionusePet<TData=Awaited<ReturnType<typeofpet>>,TError=Promise<Error>,>(// The actual implementation has the correct typespetId: string|undefined|null,options?: {query?: Partial<UseQueryOptions<Awaited<ReturnType<typeofpet>>,TError,TData>>;fetch?: RequestInit;},): UseQueryResult<TData,TError>&{queryKey: QueryKey}{constqueryOptions=getPetQueryOptions(petId,options);constquery=useQuery(queryOptions)asUseQueryResult<TData,TError>&{queryKey: QueryKey;};query.queryKey=queryOptions.queryKey;returnquery;}
What were you expecting to happen?
The optional parameter would be allowed in all overloads
Any other comments?
This PR added overloads to all hooks to allow for proper typing of the response when supplying initialData. However, these overloads don't consider the allParamsOptional option for the path parameters resulting in 3 function signatures that don't allow for undefined path parameters while the actual implementation does allow for it.
The problem is that these function overloads use the definition of the endpoint rather than the implementation and the allParamsOptional config setting only applies to the implementation of the endpoint's definition. However, the function overloads cannot use the implementation because the implementation also includes the default values which you cannot define in function overloads. We would need something that's in between the definition and implementation that does include the | undefined | null from the allParamsOptional setting but does not include the default parameters from the implementation.
What are the steps to reproduce this issue?
allParamsOptional
option in the configreact-query
clientOpenAPI sample spec:
orval.config.ts:
What happens?
You get a Typescript error:
Generated overloads:
What were you expecting to happen?
The optional parameter would be allowed in all overloads
Any other comments?
This PR added overloads to all hooks to allow for proper typing of the response when supplying
initialData
. However, these overloads don't consider theallParamsOptional
option for the path parameters resulting in 3 function signatures that don't allow forundefined
path parameters while the actual implementation does allow for it.The problem is that these function overloads use the
definition
of the endpoint rather than theimplementation
and theallParamsOptional
config setting only applies to theimplementation
of the endpoint's definition. However, the function overloads cannot use theimplementation
because theimplementation
also includes the default values which you cannot define in function overloads. We would need something that's in between thedefinition
andimplementation
that does include the| undefined | null
from theallParamsOptional
setting but does not include the default parameters from theimplementation
.What versions are you using?
The text was updated successfully, but these errors were encountered: