提交 a1374471 编写于 作者: V Vincent Cordobes 提交者: Joe Haddad

Improve NextApiResponse typing (#7841)

* Fix NextApiResponse.status type signature

* Improve NextApiResponse typing
上级 ce8956ae
......@@ -160,21 +160,21 @@ export type NextApiRequest = IncomingMessage & {
/**
* Send body of response
*/
type Send = (body: any) => void
type Send<T> = (body: T) => void
/**
* Next `API` route response
*/
export type NextApiResponse = ServerResponse & {
export type NextApiResponse<T = any> = ServerResponse & {
/**
* Send data `any` data in reponse
*/
send: Send
send: Send<T>
/**
* Send data `json` data in reponse
*/
json: Send
status: (statusCode: number) => void
json: Send<T>
status: (statusCode: number) => NextApiResponse<T>
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册