Repository navigation
Conversation
Nullable fields become T | null. Other sites use ! / null! / definite assignment, all of which are erased, so built/ is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
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.
Closes #73.
What this does
Turns on
strictNullChecksintsconfig.json.test/tsconfig.jsoninherits it, sonpm run typecheckin CI now checks null handling insrc/andtest/.This PR changes types only. Every edit is a type annotation,
!,null!,let x!: Toras HTMLElement. TypeScript removes all of these when it compiles, sobuilt/is byte-for-byte identical. Check:rm -rf built && npm run build && git status built/shows nothing. CI's built-is-up-to-date step checks the same thing.The diff replaces 134 lines in place, plus one new line in
tsconfig.json. Line numbers don't move, somasterlinks in the follow-up issues stay accurate.How each error was fixed
null)T | nullnullfor invalid input (parseCannonInput,parseMovementsInput,parseFoodCallsInput,parseRunnerMovementsToCheck,convertCommandsStringToMap,getControlledPlayerObject), plus the locals that hold their result before a null checkT | nullx === null ? null : x.clone()inclone()for fields that are never null while the sim runsnull!in that branchsim.tsas HTMLElement, the same idiomsim.tsalready uses. All 15 ids are present inindex.html.!(see below)clone()branchesnull!parseCannonInputwith valid input!(the existingnot.toBeNull()checks still run)I didn't make
position,destination,map, the five players and similar fields nullable. Nothing sets them to null while the sim runs. Only the defensiveclone()branches and the tests that cover them do. Making themT | nullwould put a!on almost every read ofposition.The
!sitesEach
!claims the value can't be null there. Running the code can't show that, so an independent reader re-derived each claim from the code without seeing my reasons:BarbarianAssault.ts:320, 325, 328, 351, 354prePositionsmaps are set for every player before the readBarbarianAssault.ts:561, 604, 647, 690, 733,sim.ts:2659get()right afterhas()HealerCodeAction.ts:62, 74, 79groupOrderonly holds set keysHealerPenance.ts:421, 440instanceofchecks ontargetPlayer.ts:269(let currentPosition!)Renderer.ts:25getContext("2d")on the page's<canvas>RunnerPenance.ts:57diedThisTickis always false there, so this branch never runssim.ts:2527(h\d+,\d+)(-h\d+,\d+)+sim.ts:473-477(reset())sim.ts:2737-2741(Simulate)The two
sim.tscases keep their!so behaviour is unchanged. #79 fixes them for real, and its fix lets those!be removed.Verified
npm run typecheckis clean, and all 295 tests pass.built/is identical after a clean rebuild.BarbarianAssaultwith a null command map throws on its firsttick().Found along the way
destinationstarts as the same object as itsposition(not reproduced, un-triaged)Not included
=== nullbranches inclone(). That changes the compiled JS, so it belongs in deduplicate per-player command dispatch and clone loops #70.strict, e.g. the ~20 fields that are never initialised. That's a separate check.🤖 Generated with Claude Code