Description
In the type definition of ClientMethod, init parameter is a rest parameter (...init), and its type is MaybeOptionalInit<Paths[P], M>, which is an Array.
However, when this type is used, in createClient, only the first element is ever used in the return value.
For example:
/** Call a POST endpoint */
POST(url, init) {
return coreFetch(url, { ...init, method: "POST" });
},
This is because init in the implementation of POST (and of all the other methods) is not a rest parameter, and so it only captures the first value.
The MaybeOptionalInit is actually always an array of 1 element (and the type is defined as such). However, when the type is captured, it's not obvious in all contexts.
Reproduction
It's a type issue, so it nothing happens at runtime.
Expected result
MaybeOptionalInit looks like it could be a simple value, not an Array. It would make it easier to capture the types of the parameters when wrapping the Client object into a decorator.
Checklist
Description
In the type definition of
ClientMethod,initparameter is a rest parameter (...init), and its type isMaybeOptionalInit<Paths[P], M>, which is an Array.However, when this type is used, in
createClient, only the first element is ever used in the return value.For example:
This is because
initin the implementation of POST (and of all the other methods) is not a rest parameter, and so it only captures the first value.The
MaybeOptionalInitis actually always an array of 1 element (and the type is defined as such). However, when the type is captured, it's not obvious in all contexts.Reproduction
It's a type issue, so it nothing happens at runtime.
Expected result
MaybeOptionalInitlooks like it could be a simple value, not an Array. It would make it easier to capture the types of the parameters when wrapping theClientobject into a decorator.Checklist