fix(lint): TS2345 noUncheckedIndexedAccess in missed-substrate-detector.ts parseArgs#3013
Merged
Merged
Conversation
…or.ts argv[i] inside a for-loop bounded by i < argv.length is always defined, but noUncheckedIndexedAccess makes it string|undefined. Set<string>.has() requires string, so KNOWN_FLAGS.has(arg) on line 87 fails. Fix: assert ! at the source (line 82) — same class as TS2532 fixes in PR #3010. Sibling fix to PR #3010 (standing-by-detector + backlog-ready-notifier test files). The source file bug was introduced in #3008 (B-0442.1) and was masked there by a companion fix commit that only covered the test file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Trivial lint fix adding a non-null assertion on argv[i] in parseArgs to satisfy noUncheckedIndexedAccess so tsc tools CI passes. The loop condition guarantees presence at runtime; only the type system needs the hint.
Changes:
- Add
!toargv[i]indexing inparseArgsloop.
2 tasks
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.
Summary
tools/bg/missed-substrate-detector.tsline 82:argv[i]→argv[i]!Root cause:
noUncheckedIndexedAccess: trueintsconfig.jsonmakesargv[i]returnstring | undefined. The loop conditioni < argv.lengthguarantees the element exists at runtime, but TypeScript can't narrow through it.Set<string>.has()requiresstring, notstring | undefined, soKNOWN_FLAGS.has(arg)at line 87 fails with TS2345.Why missed in #3008: B-0442.1 included a
fix(tsc)commit forresults[0]!in the test file but the source file'sargv[i]indexing was a separate violation that only surfaces whenlint (tsc tools)CI runs against the merge commit (which combines the PR branch with main's state).Sibling to #3010 (which fixed the same class of errors in the two test files for B-0440.1 and B-0441.1).
Test plan
bun --bun tsc --noEmit -p tsconfig.jsonpasses locally (zero errors)🤖 Generated with Claude Code