Skip to content

fix(ts): align [lang]/layout params with Next 16 LayoutProps (Class 5)#46

Open
abdout wants to merge 1 commit into
fix/auth-restore-session-providerfrom
fix/layout-props-typing
Open

fix(ts): align [lang]/layout params with Next 16 LayoutProps (Class 5)#46
abdout wants to merge 1 commit into
fix/auth-restore-session-providerfrom
fix/layout-props-typing

Conversation

@abdout
Copy link
Copy Markdown
Contributor

@abdout abdout commented Apr 25, 2026

Summary

  • Class 5 audit error: Next 16's `LayoutConfig<"/[lang]">` expects `params: Promise<{ lang: string }>` but the layout declared `Promise<{ lang: Locale }>` (narrowed).
  • Loosens to `string` + internal validation via `resolveLocale()` helper that falls back to `i18n.defaultLocale` for unknown segments.

Stacked on #10

Base branch: `fix/auth-restore-session-provider`. This PR depends on #10 landing first. When #10 merges to main, this PR's base auto-rebases and merges cleanly. Just review the diff (5 lines added).

Changes

  • `src/app/[lang]/layout.tsx` — `generateMetadata` and `LocaleLayout` params: `Locale` → `string`; new `resolveLocale()` helper.

Test plan

  • `pnpm tsc --noEmit` no longer reports the 2 `validator.ts` errors
  • `/en` and `/ar` still work
  • Invalid locale URL falls back to default (proxy.ts handles redirect; layout-side fallback is defense-in-depth)

Closes #45

🤖 Generated with Claude Code

Next 16's auto-generated LayoutConfig<"/[lang]"> expects
params: Promise<{ lang: string }> but the layout was declaring
params: Promise<{ lang: Locale }> (narrowed). The narrower type
was an over-promise.

Loosens params to string and validates inside via a small
resolveLocale() helper that falls back to i18n.defaultLocale for
unknown segments. Applied to both generateMetadata and LocaleLayout.

Stacked on fix/auth-restore-session-provider (PR #10) — auto-merges
when that lands.

Closes #45

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

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

Project Deployment Actions Updated (UTC)
marketing Ready Ready Preview, Comment Apr 25, 2026 4:28pm

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.

1 participant