refactor(game): extract undo.ts + drop undo as-any casts (Phase 2 of #132)#137
Merged
nodots merged 2 commits intoJul 15, 2026
Merged
Conversation
Move undoLastInActivePlay and canUndoActivePlay into src/Game/undo.ts as free functions. Now that types promotes undo.frames to a typed BackgammonGameMoving[] on BasePlay, the functions read game.activePlay.undo.frames directly with no 'as any' casts (removes 5 casts from the undo slice of #96). The public Game.* statics remain as thin delegating wrappers; canUndoActivePlay (deferred from guards) lands here with its concern. Depends on backgammon-types refactor/undo-frames-typed. Characterization tests (10) added in the prior commit stay green. No behavior change. Core: 458 passed / 12 skipped, tsc -b clean. Refs #132, #96
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.
Phase 2 of the Game/index.ts decomposition epic (#133)
Stacked on #136 (Phase 1). Base is
refactor/game-decomp-phase1-guards; retarget todevelopmentonce #135 and #136 merge.Depends on backgammon-types PR nodots/backgammon-types#68 — the
undo.framestyping must land (and publish) for the cast removal to typecheck against the released types package.What changed
Game.canUndoActivePlay/Game.undoLastInActivePlay(defensive/guard branches + a real-move push→pop happy path).src/Game/undo.ts—undoLastInActivePlayandcanUndoActivePlayas free functions.as anyremoval (chore: Eliminateas anycasts in Game/index.ts with proper type definitions #96) — withundo.framesnow typedBackgammonGameMoving[]onBasePlay, the functions readgame.activePlay.undo.framesdirectly; 5 casts removed from the undo slice.Game.*statics remain thin delegating wrappers.canUndoActivePlay(deferred from the guards phase) lands here with its concern.Verification
tsc -b --forcecleannpx jest: 458 passed / 12 skipped (448 baseline + 10 new)Game.*surface unchangedRefs #132, #96, #134