Repository navigation
Prove the array indexing the types only asserted - #15
Merged
Merged
Conversation
gridiron is the first consumer whose tsconfig sets noUncheckedIndexedAccess, and it typechecks this package's source because we ship raw src/. Eight errors surfaced in concierge.tsx that no other site could see — none of them new, all of them the same shape: an index read whose presence was asserted by a return type rather than proven. - readCookie destructured match[1] behind `if (!match)`, which narrows the match but not the group. The catch branch then reached for match[1] again, where `value` was already the same string. - parseRgba declared a 4-tuple return and built it from m[1..4] unchecked. Now the groups are destructured and checked, and a null match falls through the same branch — identical behaviour, provable arity. - luminance destructured a .map() result as a 3-tuple. A mapped array is number[], so each channel was number | undefined. Mapping each channel through one srgb() keeps the arity in the types. Behaviour is unchanged, and "unchanged" is tested rather than asserted: auto-theme now has a test that a dark page and a light page resolve to DIFFERENT bar backgrounds. Forcing parseRgba to null fails it; forcing luminance to 1 fails it. Without that pair the test would pass vacuously on a shared fallback. (jsdom implements no hit-testing, so elementFromPoint is stubbed.) Scope is concierge.tsx only — the entry gridiron imports. article-toc.tsx and bento-grid.tsx carry the same class of error and are left for whoever first consumes them strictly. Suite 42/42 · typecheck clean · concierge.tsx clean under --strict --noUncheckedIndexedAccess. 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.
Unblocks the gridiron integration. No behaviour change — and that claim is tested, not asserted.
What surfaced this
gridiron is the first consumer whose tsconfig sets
noUncheckedIndexedAccess(marque and the rest don't), and because this package ships rawsrc/, the consumer typechecks our source. Eight errors appeared inconcierge.tsxthat no other site could see.None are new. All are the same shape: an index read whose presence was asserted by a return type rather than proven.
readCookieif (!match)narrows the match, not the group;catchthen re-readmatch[1]catchreturns thevalueit already hadparseRgbam[1..4]uncheckedluminance.map()result as a 3-tuple — it'snumber[], so each channel wasnumber | undefinedsrgb()per channel, arity kept in the types"Unchanged" is tested
Neither helper is exported, so the honest test is the observable one: does auto-theme still tell a dark page from a light one?
That assertion exists because the vacuous version is the trap — if
parseRgbareturnednullfor both, they'd land on the same fallback and a weaker test would pass. Mutations confirm it bites:parseRgbaalwaysnullluminancealways1jsdom implements no hit-testing, so
elementFromPointis stubbed — the auto path samples whatever sits under the bar.Scope
concierge.tsxonly — the entry gridiron imports.article-toc.tsxandbento-grid.tsxcarry the same class of error and are left for whoever first consumes them strictly; fixing them here would be unverified churn in files this PR has no reason to touch.Verification
typecheckcleanconcierge.tsxclean under--strict --noUncheckedIndexedAccessPublishing is tag-triggered, so merging this does not release it.
🤖 Generated with Claude Code