You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To always adding the overlay: { ...state.overlayData, [action.overlay.id]: action.overlay }
When isExisted is true, the first if block already handles the reopen case
The final return statement only executes when adding a completely new overlay
Motivation and Context
Both pieces of code represent unreachable paths:
Redundant null check: The outer if condition state.overlayData[action.overlay.id] != null && state.overlayData[action.overlay.id].isOpen === false already ensures the overlay exists and is closed, making the inner check impossible to trigger.
Unreachable ternary branch: When execution reaches the final return statement:
If overlayData[id] exists and is closed → handled by first if block
If overlayData[id] exists and is open → throws error
If overlayData[id] doesn't exist → new overlay, must be added to overlayData
Therefore, isExisted can only be true if there's data inconsistency between overlayOrderList and overlayData, which shouldn't happen in normal operation.
Removing this dead code improves clarity and maintainability.
How Has This Been Tested?
Verified existing unit tests in packages/src/context/reducer.test.ts pass
Confirmed TypeScript compilation succeeds without type errors
No behavioral changes - the logic flow remains identical
Screenshots (if appropriate):
This change improved test coverage to 100%.
Before
After
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Documentation update
Checklist
I have performed a self-review of my own code.
My code is commented, particularly in hard-to-understand areas.
I have made corresponding changes to the documentation.
My changes generate no new warnings.
I have added tests that prove my fix is effective or that my feature works.
New and existing unit tests pass locally with my changes.
Any dependent changes have been merged and published in downstream modules.
Further Comments
This refactoring removes two pieces of unreachable code without changing any behavior. The control flow analysis shows that both the redundant null check and the isExisted ternary branch can never execute in practice, making them safe to remove.
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6a96688) to head (3452bd6). ⚠️ Report is 3 commits behind head on main.
❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
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
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.
Description
This PR removes two pieces of dead code in the
ADDaction of the overlay reducer that can never be executed due to the control flow logic.Changes
Removed redundant
if (overlay == null || overlay.isOpen)checkSimplified the ternary operator for
overlayDataisExisted ? state.overlayData : { ...state.overlayData, [action.overlay.id]: action.overlay }{ ...state.overlayData, [action.overlay.id]: action.overlay }isExistedis true, the firstifblock already handles the reopen caseMotivation and Context
Both pieces of code represent unreachable paths:
Redundant null check: The outer
ifconditionstate.overlayData[action.overlay.id] != null && state.overlayData[action.overlay.id].isOpen === falsealready ensures the overlay exists and is closed, making the inner check impossible to trigger.Unreachable ternary branch: When execution reaches the final return statement:
overlayData[id]exists and is closed → handled by firstifblockoverlayData[id]exists and is open → throws erroroverlayData[id]doesn't exist → new overlay, must be added tooverlayDataTherefore,
isExistedcan only be true if there's data inconsistency betweenoverlayOrderListandoverlayData, which shouldn't happen in normal operation.Removing this dead code improves clarity and maintainability.
How Has This Been Tested?
packages/src/context/reducer.test.tspassScreenshots (if appropriate):
This change improved test coverage to 100%.
Types of changes
Checklist
Further Comments
This refactoring removes two pieces of unreachable code without changing any behavior. The control flow analysis shows that both the redundant null check and the
isExistedternary branch can never execute in practice, making them safe to remove.