import { IncomingMessage, ServerResponse } from "http" // ------------------------------------------------------ // Types from next@10, // see: https://github.com/microsoft/dtslint/issues/297 // ------------------------------------------------------ export interface NextApiRequest extends IncomingMessage { query: { [key: string]: string | string[] } cookies: { [key: string]: string } body: any env: any preview?: boolean previewData?: any } export type Send = (body: T) => void export type NextApiResponse = ServerResponse & { send: Send json: Send status: (statusCode: number) => NextApiResponse redirect: ((url: string) => NextApiResponse) & ((status: number, url: string) => NextApiResponse) setPreviewData: ( data: object | string, options?: { maxAge?: number } ) => NextApiResponse clearPreviewData: () => NextApiResponse } export type NextApiHandler = ( req: NextApiRequest, res: NextApiResponse ) => void | Promise