From 58477b68276ac4c56da23f175d3b5355e20b6f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20de=20la=20Martini=C3=A8re?= Date: Tue, 18 Feb 2020 14:04:38 +0100 Subject: [PATCH] Add NextApiHandler type --- packages/next/next-server/lib/utils.ts | 6 ++++++ packages/next/types/index.d.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/next/next-server/lib/utils.ts b/packages/next/next-server/lib/utils.ts index 3d7a6f8ddde8e..b65a310b201f3 100644 --- a/packages/next/next-server/lib/utils.ts +++ b/packages/next/next-server/lib/utils.ts @@ -219,6 +219,12 @@ export type NextApiResponse = ServerResponse & { clearPreviewData: () => NextApiResponse } +/** + * Next `API` route handler + */ +export type NextApiHandler = (req: NextApiRequest, res: NextApiResponse) => void; + + /** * Utils */ diff --git a/packages/next/types/index.d.ts b/packages/next/types/index.d.ts index b559b5150b549..f0a1bfc0897a6 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -9,6 +9,7 @@ import { NextComponentType, NextApiResponse, NextApiRequest, + NextApiHandler, // @ts-ignore This path is generated at build time and conflicts otherwise } from '../dist/next-server/lib/utils' @@ -53,6 +54,12 @@ export type PageConfig = { } } -export { NextPageContext, NextComponentType, NextApiResponse, NextApiRequest } +export { + NextPageContext, + NextComponentType, + NextApiResponse, + NextApiRequest, + NextApiHandler, +} export default next