Skip to content

fix: preserve static param list inference with TypeScript 7#13188

Merged
satya164 merged 2 commits into
react-navigation:7.xfrom
WookieFPV:7.x-typescript-v7
Jul 17, 2026
Merged

fix: preserve static param list inference with TypeScript 7#13188
satya164 merged 2 commits into
react-navigation:7.xfrom
WookieFPV:7.x-typescript-v7

Conversation

@WookieFPV

Copy link
Copy Markdown

Motivation

TypeScript v7 (and typescript 6 with --stableTypeOrdering) broke static navigation type inference for me:
TS2315: Type 'StaticParamList' is not generic.
StaticParamList started being treated as non-generic, which caused inferred route names/params to collapse.

This small type-only change fixes the issue by tightening the internal static screen map constraint from Record<string, any> to Record<string, unknown>. I’m not fully sure why this specific shape trips TS7’s circular type alias handling, but this keeps the existing inference working.

Test plan

Added a type-level regression test for nested static navigation inference.

Related

(or typescript 6 with --stableTypeOrdering)
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.88%. Comparing base (e8a05bb) to head (9ab58a3).
⚠️ Report is 129 commits behind head on 7.x.

Additional details and impacted files
@@            Coverage Diff             @@
##              7.x   #13188      +/-   ##
==========================================
+ Coverage   77.37%   78.88%   +1.50%     
==========================================
  Files         230      237       +7     
  Lines        7519     8094     +575     
  Branches     3061     3335     +274     
==========================================
+ Hits         5818     6385     +567     
- Misses       1647     1653       +6     
- Partials       54       56       +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@satya164 satya164 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR.

Lets remove the changes from StaticNavigation.test.tsx - that file is for runtime tests.

We have type tests in __typechecks__ with StaticParamList already

expectTypeOf<MyParamList>().toEqualTypeOf<{

But these don't produce any errors with TypeScript 7 (e.g. in this WIP PR #13163). So there maybe some other factors.

Edit: Maybe this is a React Navigation 7 specific issue, haven't tested those types with TS7 yet, and since TS7 doesn't have API for ESLint plugin etc. yet, can't upgrade yet.

@WookieFPV

Copy link
Copy Markdown
Author

Thank you for the guidance!

These tests fit much better. With the new test, tsc fails without the type change in packages/core/src/types.tsx, so it now catches the regression directly.

@satya164 satya164 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks

@satya164
satya164 merged commit 7c51d7d into react-navigation:7.x Jul 17, 2026
10 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.

2 participants