Skip to content

docs: fix TypeScript type mismatch in refresh token rotation example#13396

Merged
Bekacru merged 1 commit intonextauthjs:mainfrom
nemo0824:docs/fix-refresh-token-rotation-type-guard
Apr 12, 2026
Merged

docs: fix TypeScript type mismatch in refresh token rotation example#13396
Bekacru merged 1 commit intonextauthjs:mainfrom
nemo0824:docs/fix-refresh-token-rotation-type-guard

Conversation

@nemo0824
Copy link
Copy Markdown
Contributor

Closes #13281

Problem

The issue reporter suggested changing account.access_token to user.access_token, but that's a misdiagnosis.

The real problem is a TypeScript type mismatch:

  • Account extends Partial<TokenEndpointResponse>, so access_token is string | undefined
  • Account.expires_at is declared as expires_at?: number, also optional
  • But the augmented JWT interface declares access_token: string and expires_at: number as required

This causes a TypeScript compile error when following the documentation as written.

Fix

Added a type guard before assigning account.access_token and account.expires_at to the token, consistent with the existing if (!token.refresh_token) throw new TypeError(...) pattern already used later in the same callback.

Also removed the unused type User import.

Changes

  • Remove unused type User import
  • Add if (!account.access_token || !account.expires_at) type guard with TypeError

Account 타입의 access_token과 expires_at이 optional인데 JWT 인터페이스는
required로 선언해 타입 불일치가 발생하는 문제 수정 (이슈 nextauthjs#13281)

- 미사용 `type User` import 제거
- account 블록에 access_token, expires_at 존재 여부 타입 가드 추가
@nemo0824 nemo0824 requested a review from ndom91 as a code owner March 20, 2026 02:08
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
auth-docs Ready Ready Preview, Comment Mar 20, 2026 2:15am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
next-auth-docs Ignored Ignored Preview Mar 20, 2026 2:15am

Request Review

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 20, 2026

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

A member of the Team first needs to authorize it.

@Bekacru Bekacru merged commit 2018202 into nextauthjs:main Apr 12, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: The JWT refresh token rotation example is not working correctly

2 participants