nextjs - ✅(Solved) Fix Argument of type 'string' is not assignable to parameter of type 'RedirectType | undefined' [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#88627Fetched 2026-04-08 02:04:16
View on GitHub
Comments
2
Participants
3
Timeline
11
Reactions
0
Author
Timeline (top)
commented ×2labeled ×2closed ×1cross-referenced ×1

Error Message

app/page.tsx:4:28 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'RedirectType | undefined'. Found 1 error in app/page.tsx:4

Fix Action

Fixed

PR fix notes

PR #88653: fix: make RedirectType constant properties literal types

Description (problem / solution / changelog)

What?

Fixed TypeScript error where RedirectType.replace and RedirectType.push were typed as string instead of literal types, causing compilation errors when used with redirect().

Why?

RedirectType constant properties weren't properly typed as literal types, causing TypeScript to see them as generic string values instead of the expected 'push' | 'replace' union.

How?

  • Added as const to RedirectType properties in packages/next/src/client/components/navigation.react-server.ts.

Fixes #88627

Changed files

  • packages/next/src/client/components/navigation.react-server.ts (modified, +1/-1)
  • test/integration/app-types/src/app/type-checks/redirect/page.tsx (modified, +6/-1)

Code Example

app/page.tsx:4:28 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'RedirectType | undefined'.

4  return redirect("/admin", RedirectType.replace);
                             ~~~~~~~~~~~~~~~~~~~~


Found 1 error in app/page.tsx:4

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Fri Dec  5 23:12:37 PST 2025; root:xnu-12377.80.260.0.1~42/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.17.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.26.0
Relevant Packages:
  next: 16.1.1-canary.29 // Latest available version is detected (16.1.1-canary.29).
  eslint-config-next: N/A
  react: 19.3.0-canary-bb8a76c6-20260115
  react-dom: 19.3.0-canary-bb8a76c6-20260115
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/typeofweb/redirect-next-reproduction

To Reproduce

  1. Open the codebase
  2. Look at /app/page.tsx

Current vs. Expected behavior

Currenty behavior

app/page.tsx:4:28 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'RedirectType | undefined'.

4  return redirect("/admin", RedirectType.replace);
                             ~~~~~~~~~~~~~~~~~~~~


Found 1 error in app/page.tsx:4

Expected behavior

No errors.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Fri Dec  5 23:12:37 PST 2025; root:xnu-12377.80.260.0.1~42/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.17.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.26.0
Relevant Packages:
  next: 16.1.1-canary.29 // Latest available version is detected (16.1.1-canary.29).
  eslint-config-next: N/A
  react: 19.3.0-canary-bb8a76c6-20260115
  react-dom: 19.3.0-canary-bb8a76c6-20260115
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

TypeScript

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed)

Additional context

This works fine in canary-27 and is broken in canary-28.

extent analysis

TL;DR

The issue can be fixed by updating the RedirectType usage to match the expected type, potentially by removing or adjusting the RedirectType.replace argument.

Guidance

  • Review the RedirectType definition and usage in app/page.tsx to ensure it aligns with the expected type.
  • Check the Next.js documentation for any changes to the redirect function signature between canary-27 and canary-28.
  • Verify that the RedirectType enum or type is correctly imported and used in the app/page.tsx file.
  • Consider testing the code with different RedirectType values or removing the type altogether to see if it resolves the error.

Example

No code example is provided as the issue is related to a specific type error and requires more context about the RedirectType definition.

Notes

The issue seems to be related to a change in the redirect function signature or the RedirectType type between Next.js canary-27 and canary-28. Without more information about the RedirectType definition, it's difficult to provide a more specific solution.

Recommendation

Apply workaround: Update the RedirectType usage to match the expected type, potentially by removing or adjusting the RedirectType.replace argument, as the issue is likely caused by a change in the Next.js API.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING