fix: preserve static param list inference with TypeScript 7#13188
Conversation
(or typescript 6 with --stableTypeOrdering)
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
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.
|
Thank you for the guidance! These tests fit much better. With the new test, |
Motivation
TypeScript v7 (and typescript 6 with --stableTypeOrdering) broke static navigation type inference for me:
TS2315: Type 'StaticParamList' is not generic.StaticParamListstarted 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>toRecord<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