Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
There was a problem hiding this comment.
This is a types file and should be named types.ts. Let's also move it into the NavigationService directory
app/constants/navigation/Params.ts
Outdated
|
|
||
| /** | ||
| * Navigation parameter types for all routes. | ||
| * This type mirrors the structure of Routes in Routes.ts |
There was a problem hiding this comment.
This most likely has missing items screen names since some things are hardcoded. In addition of this list, you can reference the navigation stacks to fill in the blanks.
app/constants/navigation/Params.ts
Outdated
| * Navigation parameter types for all routes. | ||
| * This type mirrors the structure of Routes in Routes.ts | ||
| */ | ||
| export interface RouteParams { |
There was a problem hiding this comment.
The RootParamsList below seems to be the correct definition. RouteParams seems duplicate and can be removed
app/constants/navigation/Params.ts
Outdated
| // Individual Parameter Types | ||
| // ============================================================================ | ||
|
|
||
| /** Browser navigation parameters */ |
There was a problem hiding this comment.
The screen params themselves should be defined in the feature directories and follow the import pattern to respect CO scopes.
5677148
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Why no E2E tests needed:
The changes improve code maintainability and TypeScript support without affecting any user-facing functionality. Performance Test Selection: |
|



Description
This PR introduces a comprehensive TypeScript type definition file (
Params.ts) for navigation parameters in the MetaMask Mobile app.Reason for the change:
Navigation in React Native apps using React Navigation benefits greatly from strong typing. Currently, route parameters are loosely typed, which can lead to runtime errors when passing incorrect or missing parameters between screens.
Improvement/Solution:
app/constants/navigation/Params.tswith ~1,267 lines of type definitionsRouteParamsinterface that mirrors the structure ofRoutes.tsBrowserParams,StakeParams,BridgeParams)GetRouteParams<T>for easy type extractionRootStackParamListfor React Navigation compatibilityChangelog
CHANGELOG entry: null
Related issues
Fixes: #23762
Manual testing steps
Feature: Navigation parameter types
Scenario: Developer uses typed navigation parameters
Given the developer imports types from app/constants/navigation/Params.ts
Before
N/A - This is a new type definition file (no visual changes)
After
N/A - This is a TypeScript type file only, no runtime or visual changes
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Type-only refactor that centralizes navigation parameter definitions; risk is limited to potential TS build/type regressions or mismatched param shapes where routes are wired.
Overview
Adds a new
app/core/NavigationService/types.tsthat defines a flattenedRootStackParamListand globally registers it with React Navigation for type-safenavigate/route params across the app.Extracts and centralizes many route param interfaces into dedicated
*.types.tsfiles (Bridge, Ramp, Earn, Stake, Card, Send, Modals, Multichain, etc.), and updates existing screens to export their param types (e.g., RampBuildQuoteParams,OrderDetailsParams, DepositKycWebviewModalParams) and re-export webview params for compatibility. Also refactors Predict navigation to use named param interfaces instead of inline route param objects.Written by Cursor Bugbot for commit 840af66. This will update automatically on new commits. Configure here.