Skip to content

fix(lint): TS2345 noUncheckedIndexedAccess in missed-substrate-detector.ts parseArgs#3013

Merged
AceHack merged 1 commit into
mainfrom
fix-ts2345-missed-substrate-detector-2026-05-13
May 13, 2026
Merged

fix(lint): TS2345 noUncheckedIndexedAccess in missed-substrate-detector.ts parseArgs#3013
AceHack merged 1 commit into
mainfrom
fix-ts2345-missed-substrate-detector-2026-05-13

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 13, 2026

Summary

  • tools/bg/missed-substrate-detector.ts line 82: argv[i]argv[i]!

Root cause: noUncheckedIndexedAccess: true in tsconfig.json makes argv[i] return string | undefined. The loop condition i < argv.length guarantees the element exists at runtime, but TypeScript can't narrow through it. Set<string>.has() requires string, not string | undefined, so KNOWN_FLAGS.has(arg) at line 87 fails with TS2345.

Why missed in #3008: B-0442.1 included a fix(tsc) commit for results[0]! in the test file but the source file's argv[i] indexing was a separate violation that only surfaces when lint (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.json passes locally (zero errors)
  • Change is minimal: 1-character addition, no logic change
  • CI lint (tsc tools) should go green on this PR

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings May 13, 2026 18:08
@AceHack AceHack enabled auto-merge (squash) May 13, 2026 18:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ! to argv[i] indexing in parseArgs loop.

@AceHack AceHack merged commit 30ac154 into main May 13, 2026
29 checks passed
@AceHack AceHack deleted the fix-ts2345-missed-substrate-detector-2026-05-13 branch May 13, 2026 18:12
AceHack added a commit that referenced this pull request May 13, 2026
…rseArgs (#3015)

argv[i] inside a bounds-checked loop (i < argv.length) is always
defined; add ! to narrow string|undefined to string so KNOWN_FLAGS.has()
and Set-typed methods accept it. Same fix pattern as PR #3013.

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants