Commit a1374471 authored by Vincent Cordobes's avatar Vincent Cordobes Committed by Joe Haddad

Improve NextApiResponse typing (#7841)

* Fix NextApiResponse.status type signature

* Improve NextApiResponse typing
parent ce8956ae
...@@ -160,21 +160,21 @@ export type NextApiRequest = IncomingMessage & { ...@@ -160,21 +160,21 @@ export type NextApiRequest = IncomingMessage & {
/** /**
* Send body of response * Send body of response
*/ */
type Send = (body: any) => void type Send<T> = (body: T) => void
/** /**
* Next `API` route response * Next `API` route response
*/ */
export type NextApiResponse = ServerResponse & { export type NextApiResponse<T = any> = ServerResponse & {
/** /**
* Send data `any` data in reponse * Send data `any` data in reponse
*/ */
send: Send send: Send<T>
/** /**
* Send data `json` data in reponse * Send data `json` data in reponse
*/ */
json: Send json: Send<T>
status: (statusCode: number) => void status: (statusCode: number) => NextApiResponse<T>
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment