Replies: 2 comments 1 reply
-
As stated in the comment, it’s to cover the really common scenario where people type if (data) {
// …
} else {
throw new Error()
} If we make that Also, to someone consuming this library, they don’t deal directly with the status code, and would be forgiven for writing this code without first consulting that an API may respond with To your point, this may not be technically correct in all scenarios. But returning How would you propose we fix this? Would it have to involve saying “never ever write |
Beta Was this translation helpful? Give feedback.
-
Hey,
I have to do this now:
If the user only wanted to check for success the "proper" way would be to do
anyway. This is not the end of the world, but caused an unintuitive bug for me that the type system did not catch. |
Beta Was this translation helpful? Give feedback.
-
I ran into this issue for an api call that may return 204.
If i check the returned data i expect it to be null
But this library explicitly sets the data to be an empty object?!
openapi-typescript/packages/openapi-fetch/src/index.js
Lines 156 to 160 in 2a4b067
Is there a reason for this?
This also breaks the type system, because it expects data to be the full object, null or undefined but not {}.
Beta Was this translation helpful? Give feedback.
All reactions