chore(predict): opt in useNavigation to AppNavigationProp (Phase 4)#33458
chore(predict): opt in useNavigation to AppNavigationProp (Phase 4)#33458weitingsun wants to merge 4 commits into
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. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Core change pattern: Every Predict component/hook/view replaces New entry points added: Risk assessment: Medium risk - while these are TypeScript-only type changes (no runtime behavior change in most cases), the removal of the cast in PredictMarketDetails is a functional improvement that should be verified. Navigation flows across deposit, cash-out, claim, withdraw, market details, positions, and feed views all touched. Tag selection rationale:
Performance Test Selection: |
⚡ Performance Test Results
✅ All tests passed · 3 tests · 1 device 📱 Devices tested (1)Android: Google Pixel 8 Pro (v14.0) ✅ Passed Tests (3)
Branch: |



Description
Phase 4 of the incremental React Navigation typing migration — Predict feature.
Predict production call sites still used untyped
useNavigation()(or the feature-localNavigationProp<PredictNavigationParamList>/NativeStackNavigationProp<PredictNavigationParamList>), so they were checked only against the Predict param list (or the loose globalReactNavigation.RootParamList) and could not enforce route names / params against the app-wideRootStackParamList. This PR opts Predict into the strict path viauseNavigation<AppNavigationProp>()(andAppStackNavigationPropwhere stack-only APIs are needed).This is effectively types-only
What changed
Opt-in across Predict (~51 production files)
useNavigation()/useNavigation<NavigationProp<PredictNavigationParamList>>()→useNavigation<AppNavigationProp>()import type { AppNavigationProp }fromapp/core/NavigationService/typesGuard prop retype (
app/components/UI/Predict/hooks/usePredictActionGuard.ts)navigation: NavigationProp<PredictNavigationParamList>→navigation: AppNavigationProp, so callers passing the root-typed navigation no longer clash with the guardStack-only APIs use
AppStackNavigationProp(app/components/UI/Predict/views/PredictBuyWithAnyToken/hooks/usePredictBuyActions.ts)useNavigation<NativeStackNavigationProp<PredictNavigationParamList>>()→useNavigation<AppStackNavigationProp>()(needs native-stacktransitionEndevent +StackActions.pop())NativeStackNavigationPropimportRemoved a redundant cast (
app/components/UI/Predict/views/PredictMarketDetails/PredictMarketDetails.tsx)(navigation as unknown as AppNavigationProp).navigate(...)becausenavigationwas typed to the Predict stack. Now thatnavigationisAppNavigationProp, the cast (and its TODO) are gonePredictEntryPointwidened (app/components/UI/Predict/types/navigation.ts)REWARDS,GTM_MODAL,BUY_PREVIEWentry points that were already used at runtime but not part of the type unionAppStackNavigationPropJSDoc clarified (app/core/NavigationService/types.ts)transitionEnd) and remains keyed to the loose globalRootParamListduring Phase 4; preferAppNavigationPropfor strict route/param checkingChangelog
CHANGELOG entry:null
Related issues
Fixes:https://consensyssoftware.atlassian.net/browse/MCWP-675
Manual testing steps
N/A
Screenshots/Recordings
N/A
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Types-only refactor across Predict navigation; no logic changes beyond removing an unsafe cast that should now type-check correctly.
Overview
Phase 4 of the React Navigation typing migration: Predict production code now uses app-wide navigation types instead of untyped
useNavigation()orNavigationProp<PredictNavigationParamList>.Across ~50+ Predict files (components, views, hooks, contexts), call sites switch to
useNavigation<AppNavigationProp>()with imports fromcore/NavigationService/types.usePredictActionGuardnow expectsAppNavigationProp, so guarded flows align with root stack typing.usePredictBuyActionsusesAppStackNavigationPropfor stack-only APIs (e.g.transitionEnd,StackActions).In
PredictMarketDetails, Polymarket resolution Webview navigation drops the(navigation as unknown as AppNavigationProp)cast now that navigation is already root-typed.PredictEntryPointaddsREWARDS,GTM_MODAL, andBUY_PREVIEWto match runtime analytics usage.AppStackNavigationPropJSDoc notes when to prefer it vsAppNavigationPropduring Phase 4.No intended runtime behavior change—compile-time route/param checking against
RootStackParamList.Reviewed by Cursor Bugbot for commit 1c81771. Bugbot is set up for automated code reviews on this repo. Configure here.