Skip to content

fix: make RedirectType constant properties literal types#88653

Merged
ztanner merged 3 commits intovercel:canaryfrom
nehaaprasad:fix/arg-assign-redirect
Jan 16, 2026
Merged

fix: make RedirectType constant properties literal types#88653
ztanner merged 3 commits intovercel:canaryfrom
nehaaprasad:fix/arg-assign-redirect

Conversation

@nehaaprasad
Copy link
Contributor

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

nehaaprasad and others added 2 commits January 16, 2026 21:33
- Changed from property-level `as const` to object-level `as const` for
  cleaner syntax
- Added test coverage to ensure RedirectType.push and RedirectType.replace
  are properly typed as literal types when used with redirect()
Copy link
Member

@ztanner ztanner left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I've also added a test.

@ztanner ztanner enabled auto-merge (squash) January 16, 2026 18:19
@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Jan 16, 2026

Allow CI Workflow Run

  • approve CI run for commit: 8abe58f

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@ztanner ztanner merged commit 5ad737c into vercel:canary Jan 16, 2026
191 of 203 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Argument of type 'string' is not assignable to parameter of type 'RedirectType | undefined'

3 participants