Openapi-fetch with promise-like interface #1316
Replies: 2 comments
-
You could maybe try the built-in export const putClient = (...params: Parameters<typeof put>) => … But I can’t say whether or not that will infer correctly. Either way I would NOT try and declare a return type on the function; I think you’ll have a bad time trying to recreate the inference there. This library is tricky because the TS inference is quite complex and hard to recreate. But if you import some of the helper types, you may find what you need ( |
Beta Was this translation helpful? Give feedback.
-
The types got a little bit of an improvement recently, and openapi-fetch exports all its types. You can now probably just copy the function signature for I’m going to convert this into a discussion as I think this is resolved, but we can keep this open for any additional ideas / input. |
Beta Was this translation helpful? Give feedback.
-
Description
When calling REST client functions, I expect to get Resolved with data when it was a success, and Reject with an error in case of failure.
Proposal
I'm trying to wrap for openapi-fetch like this:
But I can't get the types right. Apparently
url: Parameters<typeof put>[0], init: Parameters<typeof put>[1]
does not do the trick and wrong operations are getting picked from the generated ts file.Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions