@@ -10,11 +10,21 @@ import {
10
10
stripUrlQueryAndFragment ,
11
11
} from '@sentry/utils' ;
12
12
import * as domain from 'domain' ;
13
- import { NextApiHandler , NextApiRequest , NextApiResponse } from 'next' ;
14
-
15
- // This is the same as the `NextApiHandler` type, except instead of having a return type of `void | Promise<void>`, it's
16
- // only `Promise<void>`, because wrapped handlers are always async
17
- export type WrappedNextApiHandler = ( req : NextApiRequest , res : NextApiResponse ) => Promise < void > ;
13
+ import { NextApiRequest , NextApiResponse } from 'next' ;
14
+
15
+ // These are the same as the official `NextApiHandler` type, except
16
+ //
17
+ // a) Instead of having a return type of `void | Promise<void>` (Next < 12.1.6) or `unknown | Promise<unknown>` (Next
18
+ // 12.1.6+), the unwrapped version has both.
19
+ //
20
+ // b) The wrapped version returns only promises, because wrapped handlers are always async.
21
+ //
22
+ // TODO: Fix the need for the multi-version hack. See https://github.com/getsentry/sentry-javascript/pull/5737.
23
+ export type NextApiHandler = (
24
+ req : NextApiRequest ,
25
+ res : NextApiResponse ,
26
+ ) => void | Promise < void > | unknown | Promise < unknown > ;
27
+ export type WrappedNextApiHandler = ( req : NextApiRequest , res : NextApiResponse ) => Promise < void > | Promise < unknown > ;
18
28
19
29
export type AugmentedNextApiResponse = NextApiResponse & {
20
30
__sentryTransaction ?: Transaction ;
0 commit comments