Fix: [Section] Scalable Application Structure - #343
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a new documentation file outlining a feature-based, scalable structure for React + Redux + TypeScript applications. The feedback points out that the dynamic store configuration example uses Record<string, any> as the accumulator type in reduce, which causes a loss of type safety for RootState. It suggests typing the accumulator as Partial<typeof AVAILABLE_FEATURES> to preserve type safety.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const enabledReducers = Object.keys(AVAILABLE_FEATURES).reduce((acc, key) => { | ||
| if (ENABLED_FEATURES.includes(key)) { | ||
| acc[key] = AVAILABLE_FEATURES[key as keyof typeof AVAILABLE_FEATURES]; | ||
| } | ||
| return acc; | ||
| }, {} as Record<string, any>); |
There was a problem hiding this comment.
Using Record<string, any> as the accumulator type in reduce causes the resulting enabledReducers object to lose all TypeScript type safety. Consequently, RootState (defined as ReturnType<typeof store.getState>) will resolve to Record<string, any> instead of a strongly-typed state object.
To preserve type safety, type the accumulator as Partial<typeof AVAILABLE_FEATURES>.
| const enabledReducers = Object.keys(AVAILABLE_FEATURES).reduce((acc, key) => { | |
| if (ENABLED_FEATURES.includes(key)) { | |
| acc[key] = AVAILABLE_FEATURES[key as keyof typeof AVAILABLE_FEATURES]; | |
| } | |
| return acc; | |
| }, {} as Record<string, any>); | |
| const enabledReducers = Object.keys(AVAILABLE_FEATURES).reduce((acc, key) => { | |
| if (ENABLED_FEATURES.includes(key)) { | |
| const featureKey = key as keyof typeof AVAILABLE_FEATURES; | |
| acc[featureKey] = AVAILABLE_FEATURES[featureKey]; | |
| } | |
| return acc; | |
| }, {} as Partial<typeof AVAILABLE_FEATURES>); |
Fixes #42
This PR addresses the IssueHunt-funded issue #42.