next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

fix(ts): update `AppRouteHandlerFn` type to handle `null` response from middleware handler

Open ajstars1 opened this issue 1 year ago • 4 comments

☕️ Reasoning

In NextAuth Function in Middleware type null does not contain in overload

Before code updation 👇

Screenshot 2024-02-17 at 4 52 19 AM

Type Error: No overload matches this call.

Allow Null Return Value: The AppRouteHandlerFnContext type now includes null as a valid return value. This addresses the error: No overload matches this call : " Type 'null' is not assignable to type 'void | Response | Promise<void | Response>'"

After code updation 👇

Screenshot 2024-02-17 at 5 13 00 AM

🧢 Checklist

  • [ ] Documentation
  • [x] Tests
  • [x] Ready to be merged

🎫 Affected issues

Fixed: #10047

📌 Resources

ajstars1 avatar Feb 17 '24 00:02 ajstars1

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
auth-docs ❌ Failed (Inspect) Feb 17, 2024 0:10am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Feb 17, 2024 0:10am

vercel[bot] avatar Feb 17 '24 00:02 vercel[bot]

@ajstars1 is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Feb 17 '24 00:02 vercel[bot]

Hmm interesting.

@balazsorban44 it looks like Next.js itself just types this as unknown actually. Should we switch to that? Save ourselves some potential future trouble?

See: https://github.com/vercel/next.js/blob/canary/packages/next/src/server/future/route-modules/app-route/module.ts#L81-L91

PR which updated it last with some comments about why, etc.: https://github.com/vercel/next.js/commit/f47c40917485bac359df0e3c57d5394a7bcb1e90#diff-66b976b1650819b48a11d6d16d984057aa95192edcd52e936fbeec386fc9c8eb

ndom91 avatar Feb 24 '24 17:02 ndom91

still under review?

aifirstd3v avatar Apr 29 '24 14:04 aifirstd3v