chore(js-ts): Replace any types with proper TypeScript interfaces in RootState#320
Open
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
Open
chore(js-ts): Replace any types with proper TypeScript interfaces in RootState#320devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
Conversation
…RootState Co-Authored-By: Shannon Hittson <shannon.hittson@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: Shannon Hittson <shannon.hittson@cognition.ai>
Co-Authored-By: Shannon Hittson <shannon.hittson@cognition.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
chore(js-ts): Replace
anytypes with proper TypeScript interfaces in RootStateSummary
Replaces all 18
any-typed reducer state entries in theRootStateinterface (app/reducers/index.ts) with proper TypeScript interfaces derived from each reducer'sinitialStateand action handlers. Additionally fixes all downstream type errors surfaced by the concrete types across ~24 files.Reducers typed:
legalNotices,collectibles,privacy,bookmarks,browser,modals,settings,alert,transaction,wizard,notification,swaps,infuraAvailability,networkOnboarded,experimentalSettings,signatureRequest,rpcEvents,accountsApproach:
rpcEvents→iEventGroup,accounts→iAccountEvent), those types are imported directly.signatureRequest, a flexible inline interface is defined withstringtypes forreason/result_type(rather than importing the strictSecurityAlertResponseenum type from BlockaidBanner) to avoid cascading enum mismatches in test files and consuming components.index.tsbased on the reducer'sinitialStateshape and all action-handler mutations. JS reducers are cast asReducer<T>inbaseReducerssince TypeScript infers narrower types from theirinitialStatethan the declared interfaces allow.// TODO: Replace "any"and// eslint-disable-next-line @typescript-eslint/no-explicit-anycomments were removed.app/util/test/initial-root-state.tsnow provides concrete initial state objects instead ofundefinedfor all typed reducers.DeepPartial<RootState>annotations and corrected mock data to satisfy the new concrete types.Updates since last revision
Snapshot update: Updated
app/util/sentry/__snapshots__/utils.test.ts.snapand the corresponding mock state inutils.test.tsto reflect the new concrete initial root state. Three diffs:bookmarkschanged from{}to[](matching the reducer's array initialState), removed stalereceiveAsset/receiveModalVisiblefrommodals(not in reducer initialState), and removed nestednotification.notificationsSettings(not in reducer initialState). All unit tests now pass (10/10 shards green).Previous fixes (still included):
BrowserTab.idtype conflict: Changedapp/components/UI/Tokens/types.tsBrowserTab.idfromstringtonumberto match the browser reducer (which usesDate.now()).injectHomePageScriptsparameter: UpdatedBrowserTab.tsxandRPCMethodMiddleware.tsto acceptBookmark[]instead ofstring[].transaction.id: 123→'123',selectedAsset: ''→{},activeTab: ''→null,approvedHosts: []→{}).TransactionBlockaidBanner.tsx: Addedas SecurityAlertResponsecast when passingsecurityAlertResponsetoBlockaidBanner.initial-root-state.ts: Populated all 18 reducer states with concrete initial values matching their reducerinitialState.This is a types-only change — no runtime behavior is affected.
Review & Testing Checklist for Human
BrowserTab.id: numberchange: Verify that all code creating or passingBrowserTabobjects uses numeric IDs. The browser reducer usesDate.now(), but check if any external code (e.g., deep links, navigation params) passes string IDs that would now be silently mistyped.TransactionBlockaidBanner.tsxunsafe cast: ThesecurityAlertResponse as SecurityAlertResponsecast assumes the object fromRecord<string, unknown>satisfies theSecurityAlertResponseinterface. Verify the selector always returns a properly-shaped object, or consider adding runtime validation.originremoved from transaction state,idchanged from number to string). Verify these weren't intentionally testing edge cases that now won't be caught.initial-root-state.tshardcoded values: The concrete initial states (e.g.,signMessageModalVisible: true,searchEngine: 'DuckDuckGo',lockTime: -1) must match the actual reducerinitialStatevalues. If reducers change their defaults, this file must be updated or tests will use stale values.bookmarks: [](not{}), removedreceiveAsset/receiveModalVisiblefrom modals, and removed nestednotification.notificationsSettings. Verify these align with the actual reducer initialState values.Suggested test plan:
yarn lint:tsc) — should pass clean ✅ (verified locally; CI cancelled this check due to infrastructure issues)yarn test) — all 10 shards passed ✅Notes
app/reducers/index.tsrather than co-located with their reducers. This keeps the change minimal and avoids touching JS reducer files, but a future refactor could move types into per-reducertypes.tsfiles (likeuser/types.ts).StateFromReducerutility type still usesanyin its conditional — this is intentional and separate from the RootState typing effort.CLABot(auth),check-pr-labels(repo config),check-diff(Ruby setup on runner),audit:ci(pre-existing dependency vulnerabilities). Three checks were cancelled due to CI infrastructure cascading from the failed checks:lint:tsc,lint,test:depcheck. All code-related checks that ran passed: unit tests (10/10 shards), build, security scans, E2E gate checks.Link to Devin run: https://app.devin.ai/sessions/16d6fa47fdd54f22b2fe8f4c40ad7413
Requested by: @shannonhittson-eng