This adds generic parameters to the HttpResponse and RawHttpResponse types that allow them to specify what they're returning. If not provided the default is any, similar to the previous behaviour.
interface User {
id: numner,
name: string,
}
const resp = await z.request<User>('https://example.com/users');
resp.data.firstName // Error: Type `firstName` doesn't exist on type User, did you mean `name`.
Because of this note in the CLI docs, I've also marked the .json attribute on HttpResponse objects as @deprecated. It will now show up in the editor struck out, and suggest using .data instead. Is this deprecating .json correct in your opinion?
This adds generic parameters to the
HttpResponse
andRawHttpResponse
types that allow them to specify what they're returning. If not provided the default isany
, similar to the previous behaviour.Because of this note in the CLI docs, I've also marked the
.json
attribute onHttpResponse
objects as@deprecated
. It will now show up in the editor struck out, and suggest using.data
instead. Is this deprecating.json
correct in your opinion?