Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nextjs): Make
NextApiHandler
type version-agnostic (#5737)
In `withSentry` in the nextjs SDK, we import and use the `NextApiHandler` type provided by Next. In vercel/next.js#35166, which was released in 12.1.6, that type switched to using `uknown` rather than `void` for the function's return type. For users this isn't a problem. If they import both the type from Nextjs and `withSentry` from our SDK (which in turn imports the type), both imports will be pointed at their local version of Next, and the types will match. For us, though, it's a different story. Our dev version of Next is the lowest one the SDK supports, 10.0.8. If we link our SDK into a test app, the `NextApiHandler` we're importing will be coming from the `node_modules` in our repo, whereas the test app will be pulling the type from its own `node_modules`. And that works just fine... until you try to upgrade your test app to Next 12.1.6 or higher, at which point your app starts refusing to build because of the mismatch. Though at first it might seem that the obvious solution is just to update our dev version of Next to 12.1.6+, if we do that we'll just be back in the same place with the same problem trying to use lower versions of Next in our test apps. Thus we need the type to work for both older and newer versions, which is what this PR does.
- Loading branch information