Repository navigation
fix(docs): compare tsconfig options order-insensitively - #14
Merged
Merged
Conversation
`JSON.stringify(a) !== JSON.stringify(b)` is order-sensitive for objects, so an upstream key reordering would report drift and fail CI even when the options are semantically identical — a false positive in exactly the scenario the guard exists to handle. Canonicalize before comparing: object keys sorted recursively, array order preserved. Arrays stay order-sensitive deliberately — `paths` entries are an ordered fallback list, so a genuine reordering there must still report. Found by Copilot on erigontech/erigon#22764 and fixed there first; this propagates the same fix so the three docs sites keep an identical guard. Verified against four cases: baseline passes; upstream reordering compilerOptions keys now passes; reordering a `paths` array still fails; a real value change (target ES2022 -> ES2023) still fails. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The comment claimed "Array order IS meaningful" for tsconfig arrays in general, which overstates it: order matters for a `paths` fallback list but not for `lib` or `types`. Flagged by Copilot on erigontech/cocoon#39. The implementation is unchanged and stays correct — preserving order everywhere is the safe direction, since a reordered `lib` costs one harmless reconciliation whereas sorting arrays would silently hide a real `paths` change. Only the justification is reworded to say that rather than implying all tsconfig arrays carry ordered semantics. Comment-only; the three copies stay byte-identical (normalised). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Why
JSON.stringify(a) !== JSON.stringify(b)is order-sensitive for objects, so an upstream key reordering would report drift and fail CI even when the options are semantically identical — a false positive in exactly the scenario the guard exists to handle.Found by Copilot on erigontech/erigon#22764 and fixed there first; this propagates the same fix so the three docs sites keep an identical guard.
Fix
Objects get sorted, arrays do not. Sorting arrays too would be the tempting over-application, but
pathsentries are an ordered fallback list — that would trade a false positive for a false negative.Verification
compilerOptionskeyspathsarraytargetES2022 -> ES2023npm run check:tsconfigpasses clean after the change.🤖 Generated with Claude Code