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
A method with an optional return value gets generated as method(…): Promise<T | null>. That's correct if the server returns a JSON result of null. If the server responds with a 204 instead, the return value is undefined as the runtime is currently implemented. An alternative would be to change the runtime to return null in the 204 case, but I believe the runtime is correct here since 204 means "no content", which I'd translate as "the return value is not defined".
What did you want to happen?
The correct definition encompassing both cases should be method(…): Promise<T | null | undefined>.
The text was updated successfully, but these errors were encountered:
in most cases, an empty conjure optional<> return value means "the requested object does not exist", which I think is closer to null than to undefined. there might be other uses of conjure optional<>, but I think this is the most common.
I don't think we can distinguish a method returning optional.absent from a method returning nothing (i.e. having no return type), since we don't have the relevant part of the conjure definition at runtime. If we switched the meaning of 204 over to null, we'd have methods typed as Promise<void> actually return Promise<null>, which is a similar bug in the opposite direction. Methods returning void return no value. If you try to access the value anyway, it is undefined.
What happened?
A method with an optional return value gets generated as
method(…): Promise<T | null>
. That's correct if the server returns a JSON result ofnull
. If the server responds with a 204 instead, the return value isundefined
as the runtime is currently implemented. An alternative would be to change the runtime to returnnull
in the 204 case, but I believe the runtime is correct here since 204 means "no content", which I'd translate as "the return value is not defined".What did you want to happen?
The correct definition encompassing both cases should be
method(…): Promise<T | null | undefined>
.The text was updated successfully, but these errors were encountered: