Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ajstars1
Copy link
Contributor

@ajstars1 ajstars1 commented Feb 17, 2024

☕️ 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
  • Tests
  • Ready to be merged

🎫 Affected issues

Fixed: #10047

📌 Resources

Copy link

vercel bot commented Feb 17, 2024

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

Copy link

vercel bot commented Feb 17, 2024

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

A member of the Team first needs to authorize it.

@ndom91
Copy link
Member

ndom91 commented Feb 24, 2024

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.: vercel/next.js@f47c409#diff-66b976b1650819b48a11d6d16d984057aa95192edcd52e936fbeec386fc9c8eb

@ndom91 ndom91 changed the title fix(ts): nextauth middleware function no overloading matched #10047 fix(ts): update AppRouteHandlerFn type to handle null response from middleware handler Feb 24, 2024
@aifirstd3v
Copy link

still under review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type Mismatch Error with NextAuth Middleware Function Signature
3 participants