From c63d5564b4fd6f814640eda9d8c0c5f79bf01e40 Mon Sep 17 00:00:00 2001 From: jdalton Date: Fri, 24 Jul 2026 14:53:10 -0400 Subject: [PATCH] fix(scripts): drop unnecessary type assertions in stage-publish runner 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. --- scripts/repo/stage-publish-cli-exe.mts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/repo/stage-publish-cli-exe.mts b/scripts/repo/stage-publish-cli-exe.mts index 9861b38d8..895ca76ad 100644 --- a/scripts/repo/stage-publish-cli-exe.mts +++ b/scripts/repo/stage-publish-cli-exe.mts @@ -100,7 +100,7 @@ function resolveTriplets(spec: string): readonly CliExeTriplet[] | undefined { const parts = spec.split(',').map(part => part.trim()) const triplets: CliExeTriplet[] = [] for (let i = 0, { length } = parts; i < length; i += 1) { - const part = parts[i]! + const part = parts[i] if (!isCliExeTriplet(part)) { logger.error( `Unknown triplet "${part}" — expected one of: ${CLI_EXE_TRIPLETS.join(', ')}, or all/buildable`, @@ -190,9 +190,7 @@ async function stageTarget( } catch (e) { // Non-zero exits reject; the error carries the exit code. const errCode = - e && typeof e === 'object' && 'code' in e - ? (e as { code: unknown }).code - : undefined + e && typeof e === 'object' && 'code' in e ? e.code : undefined code = typeof errCode === 'number' ? errCode : 1 } if (code !== 0) { @@ -267,7 +265,7 @@ async function main(): Promise { let ok = true for (let i = 0, { length } = targets; i < length; i += 1) { - const target = targets[i]! + const target = targets[i] ok = guardTarget(target, version) && ok } if (!ok) { @@ -282,14 +280,14 @@ async function main(): Promise { `Plan (${dryRun ? 'dry-run' : 'PUBLISH'}, tag=${tag}, version=${version}):`, ) for (let i = 0, { length } = targets; i < length; i += 1) { - const target = targets[i]! + const target = targets[i] logger.log(` ${target.name}@${version} <- ${target.dir}`) } return } for (let i = 0, { length } = targets; i < length; i += 1) { - const target = targets[i]! + const target = targets[i] // eslint-disable-next-line no-await-in-loop const staged = await stageTarget(target, { dryRun, tag }) if (!staged) {