Repository navigation
fix(incremental): reject a tsbuildinfo tuple of the wrong length - #1050
Merged
Merged
Conversation
A `.tsbuildinfo` entry in `root`, `referencedMap`, or `resolvedRoot` that is an array with a length other than 2 made tsgo treat the file as unreadable and build without an old state. tsrs padded or truncated the array: `"referencedMap":[[5]]` gave a list ID of 0 and panicked in `to_file_path_set` (subtract with overflow), and `"root":[[1,2,3]]` was read as the range 1 to 2, so the file was not written again. Go reads these entries with `json.Unmarshal` into a `[2]int` (`buildInfo.go`, the `UnmarshalJSON` methods of `BuildInfoRoot`, `BuildInfoReferenceMapEntry`, and `BuildInfoResolvedRoot`). The `json` package of tsgo is `encoding/json/v2`, which returns an error when the JSON array length differs from the Go array length. `as_uint_tuple` now requires exactly N elements, and its comment states that rule. Tests: `buildinfo_tuple_array_length` in the `tsrs_cli` integration tests (a one-element and a three-element `referencedMap` entry, and a three-element and an empty `root` entry). Expected results are from tsgo at the pinned commit. All four fail without the fix. AI assistance: written with Claude Code.
camc314
approved these changes
Nov 20, 2026
Contributor
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
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.
A
.tsbuildinfowith"referencedMap":[[5]]made tsrs panic (attempt to subtract with overflow). With"root":[[1,2,3]]or"root":[[]], tsrs used the file and did not write it again. tsgo cannot read these files, so it builds without an old state and writes the file again.Go reads these entries into a
[2]int(BuildInfoRoot,BuildInfoReferenceMapEntry), andencoding/json/v2returns an error for an array of another length.as_uint_tuplepadded or truncated the array. It now rejects it, as Go does.Tests:
buildinfo_tuple_array_length(one and three elements inreferencedMap, three and zero inroot). All four fail without the fix.AI assistance: written with Claude Code.