fix(scripts): drop unnecessary type assertions in stage-publish runner (unblocks Check)#1436
fix(scripts): drop unnecessary type assertions in stage-publish runner (unblocks Check)#1436John-David Dalton (jdalton) wants to merge 1 commit into
Conversation
The type-aware oxlint gate (`no-unnecessary-type-assertion`, run via
`pnpm run check --all` in CI) flagged five assertions that don't change
the expression type:
- four `arr[i]!` non-null assertions in indexed for-loops (the tsconfig
does not enable `noUncheckedIndexedAccess`, so the element type is
already non-nullable)
- one `(e as { code: unknown }).code` cast inside a `'code' in e`
narrowed branch, where `e.code` is already accessible
Removing them clears the findings. These errors currently red the
`Check` job on socket-cli `main` and therefore on every open PR, so this
unblocks Check across the whole PR fleet.
|
Closing — this fix is wrong, and CI proved it. Removing the assertions clears the type-aware oxlint finding but breaks the Root cause is a fleet tooling contradiction, not a code smell in this file:
So the same The correct fix is at the config boundary — point the |
What
The 🔎 Check CI job (
pnpm run check --all) is red onmain— and therefore on every open socket-cli PR — because the type-aware oxlint gate flags five unnecessary type assertions inscripts/repo/stage-publish-cli-exe.mts:This removes those five assertions. No rule was disabled and no
oxlint-disablewas added — the code is fixed so the type-aware rule passes on its own.Why unblocking this matters
Checkgates the whole PR fleet. While it's red onmain, every PR inherits a redCheckregardless of its contents, which hides real regressions. Fixing the root cause greensCheckfor all socket-cli PRs (same fleet-wide win as thecmd-cisnapshot fix).The findings (all type-aware
no-unnecessary-type-assertion)arr[i]!in indexedforloops (lines ~103, ~270, ~285, ~292). The tsconfig does not enablenoUncheckedIndexedAccess, soarr[i]is already the non-nullable element type — the!changes nothing. Dropped the!.(e as { code: unknown }).code(line ~193) inside ane && typeof e === 'object' && 'code' in ebranch. After that narrowing,e.codeis already accessible asunknown— the cast changes nothing. Replaced withe.code.Removing an assertion the type-checker itself deems redundant is type-safe by definition (the assertion did not alter the type).
Verification (proof)
scripts/repo/stage-publish-cli-exe.mtsis a build/release script with no unit tests; the type-aware lint gate is the relevant check.main): the type-aware pass reports 5 errors — see theCheckjob on the latestmainrun.pnpm run lint:all(the same whole-tree gate that runs the--type-awareoxlint leg) passes clean:Note on the other red checks
The
🧪 Testjob still fails on the unrelatedcmd-ci.test.mtsbranch-name banner snapshot, which fails on every non-mainPR (tracked separately). This PR only addresses the🔎 Checkfailure.Note
Low Risk
Lint-only cleanup in a release script; assertions were provably redundant and runtime behavior is unchanged.
Overview
Clears five type-aware oxlint
no-unnecessary-type-assertionerrors inscripts/repo/stage-publish-cli-exe.mtsso the Check CI job can pass again.In indexed
forloops overpartsandtargets,arr[i]!becomesarr[i]because the indexed element type is already non-nullable under the script’s tsconfig. In thespawnerror handler,(e as { code: unknown }).codebecomese.codeafter the existingtypeof/'code' in enarrowing.No publish or staging behavior changes—only redundant assertions removed so
pnpm run lint:all/checkstays green.Reviewed by Cursor Bugbot for commit c63d556. Configure here.