🧹 Fix Unsafe Redux State Mutation in projectsSlice#44
🧹 Fix Unsafe Redux State Mutation in projectsSlice#44sachasayan wants to merge 3 commits intomainfrom
Conversation
- Introduced `ProjectMetaUpdate` discriminated union for type-safe property updates. - Refactored `updateMetaProperty` reducer to use a switch statement for type narrowing. - Eliminated `as any` casting of `state.activeProject`. - Added a fallback `default` case to ensure future-proofing. - Fixed logic to only set `projectHasLiveEdits` if an update occurred. Co-authored-by: sachasayan <1666034+sachasayan@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
@jules failing ci |
I've fixed the regression in |
- Fixed regression in `updateMetaProperty` where `default` case reached `never` type. - Fixed pre-existing type error in `OnboardingPage.tsx` blocking CI. - Simplified `updateMetaProperty` switch statement to be more concise while maintaining type safety for key properties. Co-authored-by: sachasayan <1666034+sachasayan@users.noreply.github.com>
|
@jules rebase |
I've rebased the branch onto the latest |
- Rebased onto latest main. - Resolved conflict in projectsSlice.ts. - Verified typecheck:web and tests pass. Co-authored-by: sachasayan <1666034+sachasayan@users.noreply.github.com>
The
updateMetaPropertyreducer inprojectsSlice.tspreviously used an unsafeas anycast to assign values to dynamic properties of theactiveProject. This bypassed TypeScript's type checking and posed a risk of runtime errors.I've refactored this to be fully type-safe by:
ProjectMetaUpdatetype that links eachProjectproperty key with its corresponding value type.updateMetaPropertyaction payload.switchstatement in the reducer to narrow the types of both the property and value, allowing for safe assignment without casting.defaultcase with a localized cast to ensure that any new properties added toProjectin the future are still handled, preventing the reducer from becoming a restrictive whitelist.projectHasLiveEditsis only updated when a change is actually applied.This improvement enhances the maintainability and reliability of the project's state management.
PR created automatically by Jules for task 16382191194992882127 started by @sachasayan