Skip to content

chore(js-ts): Replace AnyAction with RootAction for improved type safety#593

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1777384073-replace-anyaction-with-rootaction
Open

chore(js-ts): Replace AnyAction with RootAction for improved type safety#593
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1777384073-replace-anyaction-with-rootaction

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 28, 2026

Summary

Addresses the TODO in app/store/index.ts to improve type safety by replacing AnyAction with real Action types.

What changed:

  • Defined a RootAction union type in app/reducers/index.ts that combines all currently typed Redux action modules (UserAction, NavigationAction, OnboardingActionTypes, SecurityAction, SdkAction, FiatOrdersAction, iAccountActions, iEventAction) with Action<string> as a fallback for untyped JS actions and RTK slice actions.
  • Replaced AnyAction with RootAction in:
    • persistReducer call (app/store/index.ts)
    • ReduxStore type (app/core/redux/types.ts)
    • useThunkDispatch hook (app/components/hooks/useThunkDispatch.ts)
    • DeeplinkManager dispatch type (app/core/DeeplinkManager/DeeplinkManager.ts)

Why this matters:
AnyAction is { type: string; [extraProps: string]: any }, which allows accessing any property on an action object without type checking. RootAction prevents arbitrary property access without proper type narrowing, requiring consumers to narrow via switch (action.type) to get typed access to action-specific fields.

As more action modules are migrated from JS to TS (per the ongoing migration playbooks), they should be added to the RootAction union for progressively stronger type safety.

Review & Testing Checklist for Human

  • Verify tsc --noEmit passes with no new type errors introduced by the RootAction type
  • Spot-check that dispatching actions (e.g. thunks, RTK slice actions, plain JS actions) still compiles without errors across the app
  • Confirm no runtime behavioral changes — this is a types-only change with zero impact on emitted JavaScript

Notes

  • The combineReducers<RootState, any> in app/reducers/index.ts (line 182) is left as any intentionally — changing it would require all individual TS reducers to accept RootAction, which is a larger refactor tracked by a separate TODO.
  • Also removed the related TODO comment in app/core/redux/types.ts for ReduxStore.
  • Also cleaned up any-typed dispatch and removed // TODO comments in DeeplinkManager.ts.

Link to Devin session: https://app.devin.ai/sessions/9da3f26404ca4d04a2f7eed7899137eb
Requested by: @dr-phil


Open in Devin Review

Define a RootAction union type that combines all typed Redux action
modules (UserAction, NavigationAction, OnboardingActionTypes,
SecurityAction, SdkAction, FiatOrdersAction, iAccountActions,
iEventAction) with Action<string> as a fallback for untyped JS
actions and RTK slice actions.

Replace AnyAction usage in:
- persistReducer (app/store/index.ts)
- ReduxStore type (app/core/redux/types.ts)
- useThunkDispatch hook (app/components/hooks/useThunkDispatch.ts)
- DeeplinkManager (app/core/DeeplinkManager/DeeplinkManager.ts)

This prevents arbitrary property access on action objects without
proper type narrowing, improving type safety across the Redux store.
As more action modules are migrated to TypeScript, they should be
added to the RootAction union.

Co-Authored-By: Phil Bedford <phil.bedford@cognition.ai>
@staging-devin-ai-integration
Copy link
Copy Markdown

Devin Review

Status Commit
⚪ Not started

Open in Devin Review (Staging)

💡 Connect your GitHub account to enable automatic code reviews.

@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant