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(nextjs): Update params type with Promise as expected in Next.js 15 #12114

Merged
merged 3 commits into from
Nov 1, 2024

Conversation

ggallon
Copy link
Contributor

@ggallon ggallon commented Oct 24, 2024

☕️ Reasoning

Follow #12002, fix type error with auth() wapprer, update params type with Promise in handler.
Ref: Next.js Doc

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

📌 Resources

Copy link

vercel bot commented Oct 24, 2024

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

Name Status Preview Comments Updated (UTC)
auth-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 31, 2024 10:27pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
next-auth-docs ⬜️ Ignored (Inspect) Visit Preview Oct 31, 2024 10:27pm

Copy link

vercel bot commented Oct 24, 2024

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

A member of the Team first needs to authorize it.

Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I believe we should use our Awaitable here from @auth/core/types, to be compatible with Next.js 14.

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 39.21%. Comparing base (ad9ed04) to head (87af2a5).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
packages/next-auth/src/lib/types.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12114      +/-   ##
==========================================
- Coverage   39.22%   39.21%   -0.01%     
==========================================
  Files         191      191              
  Lines       29928    29929       +1     
  Branches     1291     1297       +6     
==========================================
  Hits        11738    11738              
- Misses      18190    18191       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ggallon
Copy link
Contributor Author

ggallon commented Oct 24, 2024

@balazsorban44, It's done

Copy link

github-actions bot commented Oct 24, 2024

Broken Link Checker

0 broken links found. Links organised below by source page, or page where they were found.

@ggallon
Copy link
Contributor Author

ggallon commented Oct 25, 2024

@balazsorban44 sorry, that's not the way. pnpm tsc --noEmit in locale not always cause an error (??) but every time with pnpm next build:

Type "AppRouteHandlerFnContext" is not a valid type for the function's second argument.
    Expected "Promise<any>", got "Awaitable<Record<string, string | string[]>> | undefined".
      Expected "Promise<any>", got "undefined".

@Aralf
Copy link

Aralf commented Oct 28, 2024

@balazsorban44 sorry, that's not the way. pnpm tsc --noEmit in locale not always cause an error (??) but every time with pnpm next build:

Type "AppRouteHandlerFnContext" is not a valid type for the function's second argument.
    Expected "Promise<any>", got "Awaitable<Record<string, string | string[]>> | undefined".
      Expected "Promise<any>", got "undefined".

@ggallon as the error mentions, undefined is not valid, that's because params is set as optional, it shouldn't be.


/**
* AppRouteHandlerFnContext is the context that is passed to the handler as the
* second argument.
*/
export type AppRouteHandlerFnContext = {
params?: Record<string, string | string[]>
params?: Awaitable<Record<string, string | string[]>>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
params?: Awaitable<Record<string, string | string[]>>
params: Awaitable<Record<string, string | string[]>>

@balazsorban44 balazsorban44 merged commit 6cbd6a5 into nextauthjs:main Nov 1, 2024
12 of 15 checks passed
@ggallon ggallon deleted the fix/nextjs15-promise-param branch November 2, 2024 21:40
@rpavlovs
Copy link

@balazsorban44 could you please bump the npm package version?

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.

4 participants