From 50981e3dd6994bc7254f230e399a4b79f9d80c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Mon, 9 Nov 2026 16:58:27 -0500 Subject: [PATCH] ref(lint): Enable no-unnecessary-type-assertion Co-Authored-By: Claude Opus 5.5 --- .oxlintrc.json | 1 + apps/games-api/src/index.test.ts | 2 +- apps/games-api/src/leaderboard.test.ts | 2 +- packages/cli/script/bench-sweep.ts | 2 +- packages/cli/script/bench.ts | 4 +- packages/cli/script/fragment-commands.ts | 2 +- packages/cli/script/generate-banner-image.ts | 6 +- packages/cli/script/generate-docs-sections.ts | 2 +- packages/cli/script/generate-sdk.ts | 2 +- .../cli/script/lib/output-schema-fields.ts | 2 +- .../cli/src/commands/alert/issues/edit.ts | 4 +- packages/cli/src/commands/api.ts | 2 +- packages/cli/src/commands/auth/default.ts | 2 +- packages/cli/src/commands/cli/upgrade.ts | 2 +- packages/cli/src/commands/local/server.ts | 5 +- packages/cli/src/commands/monitor/run.ts | 3 +- packages/cli/src/commands/release/list.ts | 4 +- packages/cli/src/lib/api-scope.ts | 2 +- packages/cli/src/lib/api/alerts.ts | 11 +- packages/cli/src/lib/api/events.ts | 2 +- packages/cli/src/lib/api/infrastructure.ts | 2 +- packages/cli/src/lib/api/issues.ts | 2 +- packages/cli/src/lib/api/logs.ts | 2 +- packages/cli/src/lib/api/preprod-artifacts.ts | 5 +- packages/cli/src/lib/api/projects.ts | 7 +- packages/cli/src/lib/api/releases.ts | 8 +- packages/cli/src/lib/api/replays.ts | 6 +- packages/cli/src/lib/api/teams.ts | 2 +- packages/cli/src/lib/chunk-loader.ts | 2 +- packages/cli/src/lib/command.ts | 7 +- packages/cli/src/lib/db/resilient.ts | 4 +- packages/cli/src/lib/db/utils.ts | 2 +- .../cli/src/lib/envelope/event-builder.ts | 2 +- packages/cli/src/lib/formatters/human.ts | 6 +- packages/cli/src/lib/formatters/json.ts | 2 +- packages/cli/src/lib/formatters/local.ts | 4 +- packages/cli/src/lib/help.ts | 4 +- packages/cli/src/lib/hex-id-recovery.ts | 7 +- packages/cli/src/lib/idempotent-operations.ts | 7 +- packages/cli/src/lib/interactive-login.ts | 4 +- packages/cli/src/lib/list-command.ts | 2 +- packages/cli/src/lib/mutate-command.ts | 10 +- packages/cli/src/lib/positional-parse.ts | 2 +- packages/cli/src/lib/select-ui/ink-ui.ts | 6 +- packages/cli/src/lib/sentry-client.ts | 4 +- .../cli/src/lib/suppress-sqlite-warning.ts | 2 +- packages/cli/src/lib/time-range.ts | 2 +- .../test/commands/alert/issues/list.test.ts | 14 +-- .../test/commands/alert/metrics/list.test.ts | 14 +-- .../cli/test/commands/api.property.test.ts | 10 +- packages/cli/test/commands/api.test.ts | 18 +-- .../cli/test/commands/attribute/list.test.ts | 6 +- .../cli/test/commands/auth/default.test.ts | 4 +- .../cli/test/commands/auth/status.test.ts | 2 +- .../cli/test/commands/auth/switch.test.ts | 4 +- packages/cli/test/commands/bash-hook.test.ts | 2 +- .../cli/test/commands/build/upload.test.ts | 6 +- packages/cli/test/commands/cli.test.ts | 24 ++-- .../cli/test/commands/cli/completion.test.ts | 2 +- packages/cli/test/commands/cli/fix.test.ts | 4 +- packages/cli/test/commands/cli/setup.test.ts | 6 +- .../cli/test/commands/cli/uninstall.test.ts | 2 +- .../cli/test/commands/cli/upgrade.test.ts | 12 +- .../commands/dart-symbol-map/upload.test.ts | 2 +- .../cli/test/commands/dashboard/list.test.ts | 2 +- .../dashboard/widget/preservation.test.ts | 4 +- .../debug-files/bundle-sources.test.ts | 2 +- .../test/commands/debug-files/check.test.ts | 2 +- .../test/commands/debug-files/find.test.ts | 2 +- .../debug-files/print-sources.test.ts | 2 +- .../test/commands/debug-files/upload.test.ts | 8 +- packages/cli/test/commands/event/view.test.ts | 8 +- .../cli/test/commands/games/snake.test.ts | 2 +- packages/cli/test/commands/info.test.ts | 4 +- .../test/commands/issue/list.property.test.ts | 21 ++-- packages/cli/test/commands/issue/list.test.ts | 14 +-- .../cli/test/commands/issue/plan.func.test.ts | 4 +- .../issue/resolve-commit-spec.test.ts | 2 +- packages/cli/test/commands/issue/tags.test.ts | 2 +- .../cli/test/commands/issue/utils.test.ts | 8 +- .../test/commands/local/control-plane.test.ts | 2 +- .../cli/test/commands/local/server.test.ts | 2 +- .../commands/local/session-snapshot.test.ts | 4 +- packages/cli/test/commands/org/list.test.ts | 6 +- .../cli/test/commands/project/list.test.ts | 11 +- .../test/commands/react-native/xcode.test.ts | 3 +- packages/cli/test/commands/repo/list.test.ts | 2 +- .../cli/test/commands/status/show.test.ts | 4 +- packages/cli/test/commands/team/list.test.ts | 2 +- packages/cli/test/commands/trial/list.test.ts | 2 +- .../cli/test/commands/trial/start.test.ts | 2 +- packages/cli/test/e2e/explore.test.ts | 2 +- packages/cli/test/e2e/local.test.ts | 8 +- packages/cli/test/fixtures/bench/generate.ts | 2 +- packages/cli/test/fixtures/bench/helpers.ts | 18 +-- packages/cli/test/helpers.ts | 6 +- packages/cli/test/lib/alias.property.test.ts | 4 +- .../cli/test/lib/api-client.coverage.test.ts | 116 +++++++++--------- packages/cli/test/lib/api/alerts.test.ts | 50 ++++---- .../cli/test/lib/api/code-mappings.test.ts | 2 +- .../cli/test/lib/api/conversations.test.ts | 6 +- packages/cli/test/lib/api/dashboards.test.ts | 2 +- packages/cli/test/lib/api/debug-files.test.ts | 28 ++--- .../cli/test/lib/api/dropped-events.test.ts | 2 +- .../cli/test/lib/api/events-overshoot.test.ts | 4 +- packages/cli/test/lib/api/explore.test.ts | 14 +-- .../cli/test/lib/api/infrastructure.test.ts | 2 +- .../cli/test/lib/api/integrations.test.ts | 2 +- .../cli/test/lib/api/issue-app-links.test.ts | 14 +-- packages/cli/test/lib/api/issues.test.ts | 2 +- packages/cli/test/lib/api/logs.test.ts | 24 ++-- .../cli/test/lib/api/project-dsns.test.ts | 6 +- packages/cli/test/lib/api/projects.test.ts | 4 +- packages/cli/test/lib/api/releases.test.ts | 44 +++---- packages/cli/test/lib/api/replays.test.ts | 32 ++--- .../lib/api/trace-item-attributes.test.ts | 2 +- packages/cli/test/lib/api/traces.test.ts | 38 +++--- .../cli/test/lib/app-scope-recovery.test.ts | 4 +- packages/cli/test/lib/bench/helpers.test.ts | 14 +-- packages/cli/test/lib/binary.test.ts | 15 ++- packages/cli/test/lib/bootstrap-auth.test.ts | 4 +- packages/cli/test/lib/build/dsyms.test.ts | 8 +- .../test/lib/checkin-builder.property.test.ts | 2 +- packages/cli/test/lib/chunk-loader.test.ts | 3 +- .../cli/test/lib/command-auth-guard.test.ts | 2 +- .../cli/test/lib/completion-warmup.test.ts | 2 +- packages/cli/test/lib/custom-ca.test.ts | 12 +- packages/cli/test/lib/db/model-based.test.ts | 2 +- .../lib/db/pagination.model-based.test.ts | 2 +- packages/cli/test/lib/db/repo-cache.test.ts | 2 +- .../lib/db/schema-downgrade.focused.test.ts | 2 +- packages/cli/test/lib/db/schema.test.ts | 4 +- .../cli/test/lib/delta-upgrade.mocked.test.ts | 13 +- packages/cli/test/lib/delta-upgrade.test.ts | 4 +- packages/cli/test/lib/detect-agent.test.ts | 2 +- packages/cli/test/lib/error-reporting.test.ts | 10 +- .../test/lib/formatters/chart-core.test.ts | 2 +- .../cli/test/lib/formatters/colors.test.ts | 2 +- .../lib/formatters/event-outcomes.test.ts | 4 +- .../lib/formatters/explore-timeseries.test.ts | 78 ++++++------ .../lib/formatters/human.property.test.ts | 12 +- .../cli/test/lib/formatters/human.test.ts | 10 +- .../test/lib/formatters/issue-tags.test.ts | 2 +- .../lib/formatters/local.property.test.ts | 4 +- .../cli/test/lib/formatters/local.test.ts | 8 +- packages/cli/test/lib/formatters/log.test.ts | 4 +- .../cli/test/lib/formatters/table.test.ts | 2 +- .../lib/formatters/trace.property.test.ts | 2 +- packages/cli/test/lib/ghcr.test.ts | 2 +- packages/cli/test/lib/git-commit-log.test.ts | 2 +- .../test/lib/hex-id-recovery.adapters.test.ts | 12 +- packages/cli/test/lib/id-arguments.test.ts | 2 +- .../cli/test/lib/install-ps1-script.test.ts | 2 +- .../cli/test/lib/mcp/process-handlers.test.ts | 23 ++-- packages/cli/test/lib/mcp/telemetry.test.ts | 2 +- packages/cli/test/lib/oauth.test.ts | 2 +- packages/cli/test/lib/org-list.test.ts | 16 +-- .../cli/test/lib/proguard.property.test.ts | 2 +- packages/cli/test/lib/release-notes.test.ts | 12 +- packages/cli/test/lib/resolve-target.test.ts | 2 +- .../cli/test/lib/response-cache-store.test.ts | 2 +- packages/cli/test/lib/response-cache.test.ts | 2 +- .../cli/test/lib/scan/grep.property.test.ts | 2 +- .../lib/security/custom-headers-leak.test.ts | 7 +- .../security/login-token-rc-poison.test.ts | 7 +- .../lib/security/refresh-token-poison.test.ts | 8 +- .../security/sntrys-claim-mismatch.test.ts | 7 +- .../lib/sentry-client.invalidation.test.ts | 4 +- .../lib/sentry-client.revalidation.test.ts | 4 +- packages/cli/test/lib/sentry-client.test.ts | 12 +- packages/cli/test/lib/sixel-image.test.ts | 2 +- .../test/lib/telemetry/offline-store.test.ts | 2 +- .../telemetry/offline-transport.e2e.test.ts | 5 +- .../lib/telemetry/zstd-transport.e2e.test.ts | 2 +- .../test/lib/telemetry/zstd-transport.test.ts | 4 +- .../cli/test/lib/time-range.property.test.ts | 2 +- packages/cli/test/lib/trials.test.ts | 6 +- packages/cli/test/lib/upgrade.test.ts | 4 +- packages/cli/test/lib/version-check.test.ts | 6 +- packages/cli/test/lib/wasm/helpers.ts | 2 +- packages/cli/test/lib/windows-path.test.ts | 2 +- packages/cli/test/preload.ts | 2 +- .../cli/test/script/source-api-usage.test.ts | 2 +- .../cli/test/types/dashboard.property.test.ts | 4 +- packages/cli/test/types/dashboard.test.ts | 4 +- packages/logger/tsconfig.json | 1 + .../animation/TerminalAnimation.tsx | 5 +- .../client/components/chat/chat-message.tsx | 4 +- .../src/client/components/chat/chat.tsx | 2 +- .../components/ui/interactive-markdown.tsx | 2 +- .../src/client/hooks/use-persisted-chat.ts | 2 +- .../src/server/lib/approval-dialog.ts | 6 +- .../src/server/lib/constraint-utils.test.ts | 2 +- .../src/server/lib/mcp-handler.test.ts | 6 +- .../src/server/lib/mcp-handler.ts | 2 +- .../src/server/oauth/authorize.test.ts | 86 ++++++------- .../src/server/oauth/callback.test.ts | 8 +- .../src/server/oauth/helpers.test.ts | 2 +- .../src/server/oauth/routes/authorize.ts | 2 +- .../src/server/oauth/routes/callback.ts | 4 +- .../src/server/routes/search.test.ts | 2 +- .../src/server/routes/search.ts | 3 +- .../src/server/utils/rate-limiter.test.ts | 14 +-- .../src/test-utils/configure-fetch-mock.ts | 7 +- .../mcp-core/src/api-client/client.test.ts | 8 +- .../internal/agents/callEmbeddedAgent.test.ts | 2 +- .../mcp-core/src/internal/formatting.test.ts | 4 +- packages/mcp-core/src/internal/formatting.ts | 14 +-- .../mcp-core/src/internal/fresh-reads.test.ts | 2 +- .../mcp-core/src/internal/test-fixtures.ts | 2 +- .../tool-helpers/default-organization.test.ts | 4 +- packages/mcp-core/src/permissions.ts | 2 +- packages/mcp-core/src/server.test.ts | 22 ++-- packages/mcp-core/src/skills.ts | 2 +- packages/mcp-core/src/telem/logging.ts | 2 +- .../tools/catalog/analyze-issue-with-seer.ts | 8 +- .../src/tools/catalog/find-dashboards.test.ts | 10 +- .../catalog/get-agent-conversation-details.ts | 2 +- .../tools/catalog/get-issue-activity.test.ts | 24 ++-- .../catalog/get-issue-breadcrumbs.test.ts | 8 +- .../src/tools/catalog/get-issue-details.ts | 2 +- .../src/tools/catalog/get-issue-tag-values.ts | 6 +- .../tools/catalog/get-snapshot-image.test.ts | 66 +++++----- .../search-agent-conversations.test.ts | 4 +- .../src/tools/catalog/update-issue.ts | 8 +- .../catalog/update-uptime-monitor.test.ts | 2 +- .../src/tools/support/dashboards/index.ts | 2 +- .../src/tools/support/event-stacktrace.ts | 4 +- .../tools/support/issue-linking/app.test.ts | 8 +- .../src/tools/support/issue-linking/app.ts | 10 +- .../src/tools/support/issue-linking/index.ts | 4 +- .../support/profile/details-output.test.ts | 2 +- .../tools/support/profile/details-output.ts | 2 +- .../support/profile/flamegraph-output.test.ts | 14 +-- .../search-events/dropped-events-note.test.ts | 2 +- .../src/tools/support/search-events/search.ts | 2 +- .../tools/support/search-events/utils.test.ts | 6 +- .../mcp-core/src/transports/stdio.test.ts | 2 +- packages/mcp-core/src/utils/url-utils.ts | 4 +- packages/mcp-server-mocks/src/fixtures.ts | 2 +- packages/mcp-test-client/src/agent.ts | 2 +- packages/toolkit-core/tsconfig.json | 1 + 242 files changed, 811 insertions(+), 908 deletions(-) diff --git a/.oxlintrc.json b/.oxlintrc.json index 6a86d7b0d..8295f15d3 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -37,6 +37,7 @@ "allow": ["URL", "URLSearchParams"] } ], + "typescript/no-unnecessary-type-assertion": "error", "jsx-a11y/interactive-supports-focus": "off", "unicorn/prefer-spread": "error" }, diff --git a/apps/games-api/src/index.test.ts b/apps/games-api/src/index.test.ts index 4f7619909..eaef0053d 100644 --- a/apps/games-api/src/index.test.ts +++ b/apps/games-api/src/index.test.ts @@ -45,7 +45,7 @@ describe("worker Sentry reporting", () => { Cookie: "session=synthetic-secret", }, }, - ) as Parameters[0], + ), env, ctx, ); diff --git a/apps/games-api/src/leaderboard.test.ts b/apps/games-api/src/leaderboard.test.ts index e677c45b4..7032343e6 100644 --- a/apps/games-api/src/leaderboard.test.ts +++ b/apps/games-api/src/leaderboard.test.ts @@ -19,7 +19,7 @@ function makeEnv(overrides: Record = {}): Env { return { SENTRY_GAMES_READ_TOKEN: TOKEN, ...overrides, - } as unknown as Env; + }; } function upstreamBody(rows: Array<[unknown, unknown]>) { diff --git a/packages/cli/script/bench-sweep.ts b/packages/cli/script/bench-sweep.ts index 49cb8daf4..08fe0f125 100644 --- a/packages/cli/script/bench-sweep.ts +++ b/packages/cli/script/bench-sweep.ts @@ -75,7 +75,7 @@ function parseArgs(argv: readonly string[]): SweepArgs { const kneeThresholdPct = 0.03; // 3% for (let i = 0; i < argv.length; i += 1) { - const arg = argv[i] as string; + const arg = argv[i]; const next = argv[i + 1]; switch (arg) { case "--size": { diff --git a/packages/cli/script/bench.ts b/packages/cli/script/bench.ts index 450e62fba..b40b3dc89 100644 --- a/packages/cli/script/bench.ts +++ b/packages/cli/script/bench.ts @@ -195,7 +195,7 @@ function parseArgs(argv: readonly string[]): CliArgs { const thresholdPct = Number(process.env.BENCH_THRESHOLD ?? 0.2); for (let i = 0; i < argv.length; i += 1) { - const arg = argv[i] as string; + const arg = argv[i]; const next = argv[i + 1]; if (applyFlag(state, arg, next)) { i += 1; @@ -477,7 +477,7 @@ async function buildOps(): Promise { ".git/HEAD", ]; for (let i = 0; i < 10_000; i += 1) { - const q = queries[i % queries.length] as string; + const q = queries[i % queries.length]; stack.isIgnored(q, false); } }, diff --git a/packages/cli/script/fragment-commands.ts b/packages/cli/script/fragment-commands.ts index 9c91aba48..869d73abc 100644 --- a/packages/cli/script/fragment-commands.ts +++ b/packages/cli/script/fragment-commands.ts @@ -85,7 +85,7 @@ function parseMarker(token: Token | undefined): Marker | undefined { function childTokenLists(token: Token): Token[][] { const lists: Token[][] = []; if ("tokens" in token && Array.isArray(token.tokens)) { - lists.push(token.tokens as Token[]); + lists.push(token.tokens); } if (token.type === "list") { lists.push(token.items as Token[]); diff --git a/packages/cli/script/generate-banner-image.ts b/packages/cli/script/generate-banner-image.ts index 43979afc9..38697d0f6 100644 --- a/packages/cli/script/generate-banner-image.ts +++ b/packages/cli/script/generate-banner-image.ts @@ -56,8 +56,8 @@ function gradientAt(t: number): [number, number, number] { const seg = clamped * (GRADIENT_ANCHORS.length - 1); const i = Math.min(GRADIENT_ANCHORS.length - 2, Math.floor(seg)); const f = seg - i; - const a = GRADIENT_ANCHORS[i] as [number, number, number]; - const b = GRADIENT_ANCHORS[i + 1] as [number, number, number]; + const a = GRADIENT_ANCHORS[i]; + const b = GRADIENT_ANCHORS[i + 1]; return [ Math.round(a[0] + (b[0] - a[0]) * f), Math.round(a[1] + (b[1] - a[1]) * f), @@ -106,7 +106,7 @@ function encodePngBase64(mask: PNG): string { const model = maskModel(mask); const out = new PNG({ width: mask.width, height: mask.height }); for (let y = 0; y < mask.height; y++) { - const [r, g, b] = palette[model.bandForRow(y)] as [number, number, number]; + const [r, g, b] = palette[model.bandForRow(y)]; for (let x = 0; x < mask.width; x++) { const i = (y * mask.width + x) * 4; out.data[i] = r; diff --git a/packages/cli/script/generate-docs-sections.ts b/packages/cli/script/generate-docs-sections.ts index 70fdc10b5..fa1c3f828 100644 --- a/packages/cli/script/generate-docs-sections.ts +++ b/packages/cli/script/generate-docs-sections.ts @@ -345,7 +345,7 @@ function extractNodeVersion(): string { */ function extractDevNodeVersion(): string { const constraint: string | undefined = - (pkg as any).devEngines?.runtime?.version ?? pkg.engines?.node; + pkg.devEngines?.runtime?.version ?? pkg.engines?.node; if (!constraint) { throw new Error("Missing devEngines.runtime.version and engines.node"); } diff --git a/packages/cli/script/generate-sdk.ts b/packages/cli/script/generate-sdk.ts index 1d404eb1f..97d2a8499 100644 --- a/packages/cli/script/generate-sdk.ts +++ b/packages/cli/script/generate-sdk.ts @@ -168,7 +168,7 @@ function extractSdkFlags(command: Command): SdkFlagInfo[] { const flags: SdkFlagInfo[] = []; - for (const [name, def] of Object.entries(flagDefs) as [string, FlagDef][]) { + for (const [name, def] of Object.entries(flagDefs)) { if (INTERNAL_FLAGS.has(name)) { continue; } diff --git a/packages/cli/script/lib/output-schema-fields.ts b/packages/cli/script/lib/output-schema-fields.ts index 4c0d920aa..d52633d9e 100644 --- a/packages/cli/script/lib/output-schema-fields.ts +++ b/packages/cli/script/lib/output-schema-fields.ts @@ -204,7 +204,7 @@ export function extractSchemaFieldPaths(schema: GenericSchema): string[] { } } }; - visit(schema as unknown as ValibotSchemaNode, ""); + visit(schema, ""); return [...paths]; } diff --git a/packages/cli/src/commands/alert/issues/edit.ts b/packages/cli/src/commands/alert/issues/edit.ts index 37e96573c..1a4c53a90 100644 --- a/packages/cli/src/commands/alert/issues/edit.ts +++ b/packages/cli/src/commands/alert/issues/edit.ts @@ -147,9 +147,7 @@ function applyIssueEdits( const actionFilters = Array.isArray(body.actionFilters) ? (body.actionFilters as Record[]) : []; - const existingFilter = actionFilters[0] as - | Record - | undefined; + const existingFilter = actionFilters[0]; // When the rule has no action filter yet, a partial edit (e.g. only // --action) must still emit a valid DataConditionGroup. Seed the same // defaults the create path uses so the group carries a logicType and a diff --git a/packages/cli/src/commands/api.ts b/packages/cli/src/commands/api.ts index 1cf8d1ce7..d88748fde 100644 --- a/packages/cli/src/commands/api.ts +++ b/packages/cli/src/commands/api.ts @@ -1354,7 +1354,7 @@ export function buildFromFields( // Merge field-built key=value entries into the auto-detected JSON object body body = body && typeof body === "object" - ? { ...(body as Record), ...options.body } + ? { ...body, ...options.body } : options.body; } diff --git a/packages/cli/src/commands/auth/default.ts b/packages/cli/src/commands/auth/default.ts index c76ffcd46..2fb9c0f6d 100644 --- a/packages/cli/src/commands/auth/default.ts +++ b/packages/cli/src/commands/auth/default.ts @@ -178,7 +178,7 @@ export const authDefaultCommand = buildCommand({ async *func(this: SentryContext, flags: AuthDefaultFlags) { const target = resolveAuthDefaultTarget(flags); const command = target === "login" ? loginCommand : statusCommand; - const raw = getRawFunc(command as Command); + const raw = getRawFunc(command); const generator = raw.call( this, flags as unknown as Record, diff --git a/packages/cli/src/commands/cli/upgrade.ts b/packages/cli/src/commands/cli/upgrade.ts index 64255c179..4b4ebfc2a 100644 --- a/packages/cli/src/commands/cli/upgrade.ts +++ b/packages/cli/src/commands/cli/upgrade.ts @@ -1113,7 +1113,7 @@ function startChangelogFetch(options: { source, }) .then((result) => result ?? undefined) - .catch(() => undefined as undefined); + .catch(() => undefined); } /** diff --git a/packages/cli/src/commands/local/server.ts b/packages/cli/src/commands/local/server.ts index f77eb5ce7..8699647b1 100644 --- a/packages/cli/src/commands/local/server.ts +++ b/packages/cli/src/commands/local/server.ts @@ -435,13 +435,12 @@ export function buildApp( contentType = SENTRY_CONTENT_TYPE; } const rawEncoding = c.req.header("content-encoding"); - const contentEncoding = ( + const contentEncoding = rawEncoding === "gzip" || rawEncoding === "deflate" || rawEncoding === "br" ? rawEncoding - : undefined - ) as "gzip" | "deflate" | "br" | undefined; + : undefined; const userAgent = c.req.header("user-agent"); pushToSpotlightBuffer({ diff --git a/packages/cli/src/commands/monitor/run.ts b/packages/cli/src/commands/monitor/run.ts index f591bb864..118fe211c 100644 --- a/packages/cli/src/commands/monitor/run.ts +++ b/packages/cli/src/commands/monitor/run.ts @@ -362,8 +362,7 @@ The wrapped command receives the \`SENTRY_MONITOR_SLUG\` environment variable.`, // Map signal kills to 128+N (Unix convention: e.g. 130 for // SIGINT, 137 for SIGKILL, 143 for SIGTERM) so CI pipelines // and shell scripts inspecting $? see the correct exit code. - const sigNum = - osConstants.signals[signal as keyof typeof osConstants.signals]; + const sigNum = osConstants.signals[signal]; resolve(128 + (sigNum ?? 1)); } else { resolve(1); diff --git a/packages/cli/src/commands/release/list.ts b/packages/cli/src/commands/release/list.ts index 64b56fba6..57e3dd950 100644 --- a/packages/cli/src/commands/release/list.ts +++ b/packages/cli/src/commands/release/list.ts @@ -170,9 +170,7 @@ function formatSessionSparkline(r: SentryRelease): string { if (!health) { return ""; } - const points = extractSessionPoints( - health.stats as Record | undefined, - ); + const points = extractSessionPoints(health.stats); if (points.length === 0) { return ""; } diff --git a/packages/cli/src/lib/api-scope.ts b/packages/cli/src/lib/api-scope.ts index a33931bb4..cc5625b6b 100644 --- a/packages/cli/src/lib/api-scope.ts +++ b/packages/cli/src/lib/api-scope.ts @@ -124,7 +124,7 @@ function extractScopeCandidate(entry: unknown): string | undefined { entry && typeof entry === "object" && "scope" in entry && - typeof (entry as { scope: unknown }).scope === "string" + typeof entry.scope === "string" ) { return (entry as { scope: string }).scope; } diff --git a/packages/cli/src/lib/api/alerts.ts b/packages/cli/src/lib/api/alerts.ts index 98a6744bb..1317037be 100644 --- a/packages/cli/src/lib/api/alerts.ts +++ b/packages/cli/src/lib/api/alerts.ts @@ -425,11 +425,6 @@ export async function listMetricAlertsPaginated( sortBy: "-id", cursor: options.cursor, per_page: options.perPage, - } as { - query?: string; - sortBy?: string; - cursor?: string; - per_page?: number; }, }); const { data, nextCursor } = unwrapPaginatedResult( @@ -734,7 +729,7 @@ function buildDetectorBody( detectorBody.enabled = Number(body.status) !== 1; } if (body.owner !== undefined) { - detectorBody.owner = body.owner as string | null; + detectorBody.owner = body.owner; } return detectorBody; } @@ -846,9 +841,7 @@ export async function putMetricAlertRule( }, // `buildDetectorBody` returns the camelCase detector document as a plain // record, so cast it into the SDK's typed body. - body: buildDetectorBody(body) as unknown as Parameters< - typeof updateOrganizationDetector - >[0]["body"], + body: buildDetectorBody(body), }); return unwrapResult( result, diff --git a/packages/cli/src/lib/api/events.ts b/packages/cli/src/lib/api/events.ts index 456312b7f..3e232cc94 100644 --- a/packages/cli/src/lib/api/events.ts +++ b/packages/cli/src/lib/api/events.ts @@ -278,7 +278,7 @@ export async function listIssueEvents( // `per_page` is accepted at runtime but absent from the generated query // type, so widen via cast. per_page: perPage, - } as Parameters[0]["query"], + }, }); return unwrapPaginatedResult( result, diff --git a/packages/cli/src/lib/api/infrastructure.ts b/packages/cli/src/lib/api/infrastructure.ts index 625cbdb7a..7e21ab355 100644 --- a/packages/cli/src/lib/api/infrastructure.ts +++ b/packages/cli/src/lib/api/infrastructure.ts @@ -367,7 +367,7 @@ export function throwApiError( const status = response.status; const rawDetail = error && typeof error === "object" && "detail" in error - ? (error as { detail: unknown }).detail + ? error.detail : undefined; const hasUsableDetail = rawDetail !== null && rawDetail !== undefined; // Enrichment functions (enrich403Detail, enrich401Detail) render better diff --git a/packages/cli/src/lib/api/issues.ts b/packages/cli/src/lib/api/issues.ts index a3db4a90d..781a3e568 100644 --- a/packages/cli/src/lib/api/issues.ts +++ b/packages/cli/src/lib/api/issues.ts @@ -751,7 +751,7 @@ export async function getSharedIssue( try { result = await getOrganizationSharedIssue({ baseUrl: normalizedBase, - fetch: fetchUnauthenticated as unknown as typeof fetch, + fetch: fetchUnauthenticated, headers, parseAs: "json", path: { organization_id_or_slug: orgSlug, share_id: shareId }, diff --git a/packages/cli/src/lib/api/logs.ts b/packages/cli/src/lib/api/logs.ts index 4905ce2c0..fba77105d 100644 --- a/packages/cli/src/lib/api/logs.ts +++ b/packages/cli/src/lib/api/logs.ts @@ -218,7 +218,7 @@ export async function listLogs( start: options.start, end: options.end, sort: toApiSort(options.sort), - } as Parameters[0]["query"], + }, }); const { data: raw, nextCursor } = unwrapPaginatedResult( diff --git a/packages/cli/src/lib/api/preprod-artifacts.ts b/packages/cli/src/lib/api/preprod-artifacts.ts index 1508b5a24..8c4dcb4f5 100644 --- a/packages/cli/src/lib/api/preprod-artifacts.ts +++ b/packages/cli/src/lib/api/preprod-artifacts.ts @@ -190,10 +190,7 @@ export async function downloadBuildArtifact( } // Stream to disk so large (hundreds-of-MB) artifacts never buffer in memory. - await pipeline( - Readable.fromWeb(response.body as Parameters[0]), - createWriteStream(destPath), - ); + await pipeline(Readable.fromWeb(response.body), createWriteStream(destPath)); } /** Optional metadata sent with a build assemble request. */ diff --git a/packages/cli/src/lib/api/projects.ts b/packages/cli/src/lib/api/projects.ts index 13a2df22f..35427ed7d 100644 --- a/packages/cli/src/lib/api/projects.ts +++ b/packages/cli/src/lib/api/projects.ts @@ -81,10 +81,7 @@ export async function listProjects(orgSlug: string): Promise { const result = await listOrganizationProjects({ ...config, path: { organization_id_or_slug: orgSlug }, - query: { cursor, per_page: API_MAX_PER_PAGE } as { - cursor?: string; - per_page?: number; - }, + query: { cursor, per_page: API_MAX_PER_PAGE }, }); return unwrapPaginatedResult( result, @@ -138,7 +135,7 @@ export async function listProjectsPaginated( cursor: options.cursor, per_page: perPage, query: options.query, - } as { cursor?: string; per_page?: number; query?: string }, + }, }); return unwrapPaginatedResult( diff --git a/packages/cli/src/lib/api/releases.ts b/packages/cli/src/lib/api/releases.ts index 844ada6e9..ba0fb4f41 100644 --- a/packages/cli/src/lib/api/releases.ts +++ b/packages/cli/src/lib/api/releases.ts @@ -306,9 +306,7 @@ export async function updateRelease( organization_id_or_slug: orgSlug, version, }, - body: body as unknown as Parameters< - typeof updateOrganizationRelease - >[0]["body"], + body: body, }); return unwrapResult( @@ -394,9 +392,7 @@ export async function createReleaseDeploy( organization_id_or_slug: orgSlug, version, }, - body: body as unknown as Parameters< - typeof createOrganizationReleaseDeploy - >[0]["body"], + body: body, }); return unwrapResult(result, "Failed to create deploy"); diff --git a/packages/cli/src/lib/api/replays.ts b/packages/cli/src/lib/api/replays.ts index da24a743e..c60010411 100644 --- a/packages/cli/src/lib/api/replays.ts +++ b/packages/cli/src/lib/api/replays.ts @@ -19,7 +19,6 @@ import { ReplayDetailsResponseSchema, ReplayIdsByResourceSchema, type ReplayListItem, - type ReplayListResponse, ReplayListResponseSchema, type ReplayStringProjectId, } from "../../types/index.js"; @@ -221,10 +220,7 @@ async function fetchReplayPage( start: options.start, end: options.end, }, - schema: ReplayListResponseSchema as GenericSchema< - unknown, - ReplayListResponse - >, + schema: ReplayListResponseSchema, }, ); diff --git a/packages/cli/src/lib/api/teams.ts b/packages/cli/src/lib/api/teams.ts index 99e22a5ed..88213a512 100644 --- a/packages/cli/src/lib/api/teams.ts +++ b/packages/cli/src/lib/api/teams.ts @@ -60,7 +60,7 @@ export async function listTeamsPaginated( cursor: options.cursor, per_page: options.perPage ?? 25, query: options.query, - } as { cursor?: string; per_page?: number; query?: string }, + }, }); return unwrapPaginatedResult(result, "Failed to list teams"); diff --git a/packages/cli/src/lib/chunk-loader.ts b/packages/cli/src/lib/chunk-loader.ts index f20e17f7d..6c7ec0f3d 100644 --- a/packages/cli/src/lib/chunk-loader.ts +++ b/packages/cli/src/lib/chunk-loader.ts @@ -124,7 +124,7 @@ function suppressLoaderWarning(): void { return; } loaderWarningSuppressed = true; - const originalEmit = process.emit.bind(process) as typeof process.emit; + const originalEmit = process.emit.bind(process); process.emit = ((event: string, ...args: unknown[]) => { const [warning] = args; if ( diff --git a/packages/cli/src/lib/command.ts b/packages/cli/src/lib/command.ts index 047fed786..f86672b23 100644 --- a/packages/cli/src/lib/command.ts +++ b/packages/cli/src/lib/command.ts @@ -578,10 +578,7 @@ export function buildCommand< builderArgs.skipRcUrlCheck === true || builderArgs.auth === "dsn"; // Merge global flags into the command's flag definitions. - const existingParams = (builderArgs.parameters ?? {}) as Record< - string, - unknown - >; + const existingParams = builderArgs.parameters ?? {}; const existingFlags = (existingParams.flags ?? {}) as Record; const { mergedFlags, commandOwnsOrg, commandOwnsProject, stripKeys } = @@ -799,7 +796,7 @@ export function buildCommand< commandOwnsProject, ); - const cleanFlags = cleanRawFlags(flags as Record); + const cleanFlags = cleanRawFlags(flags); setFlagContext(cleanFlags); if (args.length > 0) { setArgsContext(args.flatMap(rawPositional)); diff --git a/packages/cli/src/lib/db/resilient.ts b/packages/cli/src/lib/db/resilient.ts index 9978940a2..2260cb6f4 100644 --- a/packages/cli/src/lib/db/resilient.ts +++ b/packages/cli/src/lib/db/resilient.ts @@ -286,7 +286,7 @@ export function createResilientDatabase( ): Database { const originalQuery = db.query.bind(db); - return new Proxy(db as object, { + return new Proxy(db, { get(target, prop) { if (prop === "query") { return (sql: string) => { @@ -316,5 +316,5 @@ export function createResilientDatabase( } return value; }, - }) as Database; + }); } diff --git a/packages/cli/src/lib/db/utils.ts b/packages/cli/src/lib/db/utils.ts index 0eeec49e1..f438e999f 100644 --- a/packages/cli/src/lib/db/utils.ts +++ b/packages/cli/src/lib/db/utils.ts @@ -63,7 +63,7 @@ export function upsert>( options: UpsertOptions = {}, ): SqlQuery { const columns = Object.keys(data); - const values = Object.values(data) as SqlValue[]; + const values = Object.values(data); if (columns.length === 0) { throw new Error("upsert: data object must have at least one column"); diff --git a/packages/cli/src/lib/envelope/event-builder.ts b/packages/cli/src/lib/envelope/event-builder.ts index 3487cabd9..2dc3fd39f 100644 --- a/packages/cli/src/lib/envelope/event-builder.ts +++ b/packages/cli/src/lib/envelope/event-builder.ts @@ -208,7 +208,7 @@ export async function buildEventFromFlags( ? { message: flags.message.join("\n"), ...(flags["message-arg"]?.length - ? { params: flags["message-arg"] as unknown[] } + ? { params: flags["message-arg"] } : {}), } : undefined, diff --git a/packages/cli/src/lib/formatters/human.ts b/packages/cli/src/lib/formatters/human.ts index 57fff8a79..f235283b1 100644 --- a/packages/cli/src/lib/formatters/human.ts +++ b/packages/cli/src/lib/formatters/human.ts @@ -582,9 +582,7 @@ function formatIssueCell(issue: SentryIssue, compact = false): string { * @returns Cell string */ function formatTrendCell(issue: SentryIssue, compact = false): string { - const points = extractStatsPoints( - issue.stats as Record | undefined, - ); + const points = extractStatsPoints(issue.stats); const graph = points.length > 0 ? colorTag("muted", sparkline(points)) : ""; const status = substatusLabel(issue.substatus); const parts = [graph, status].filter(Boolean); @@ -1025,7 +1023,7 @@ function buildBreadcrumbsMarkdown(breadcrumbsEntry: BreadcrumbsEntry): string { let message = breadcrumb.message ?? ""; if (!message && breadcrumb.data) { - const data = breadcrumb.data as Record; + const data = breadcrumb.data; if (data.url && data.method) { const status = data.status_code ? ` → ${stringifyUnknown(data.status_code)}` diff --git a/packages/cli/src/lib/formatters/json.ts b/packages/cli/src/lib/formatters/json.ts index c30e9a959..cde8c9b64 100644 --- a/packages/cli/src/lib/formatters/json.ts +++ b/packages/cli/src/lib/formatters/json.ts @@ -196,7 +196,7 @@ export function filterFields(data: T, fields: string[]): Partial { ) as unknown as Partial; } if (data === null || data === undefined || typeof data !== "object") { - return data as Partial; + return data; } const projection = projectFields(data, fields); return (projection.found ? projection.value : {}) as Partial; diff --git a/packages/cli/src/lib/formatters/local.ts b/packages/cli/src/lib/formatters/local.ts index 3f45946fb..0e0831e6c 100644 --- a/packages/cli/src/lib/formatters/local.ts +++ b/packages/cli/src/lib/formatters/local.ts @@ -604,9 +604,7 @@ export function formatSingleSpan( const semanticOp = inferSemanticOp(flat); const op = semanticOp ?? - (typeof flat["sentry.op"] === "string" - ? (flat["sentry.op"] as string) - : undefined); + (typeof flat["sentry.op"] === "string" ? flat["sentry.op"] : undefined); if (op && op !== "default" && op !== "unknown") { msg = `[${sanitize(op)}] ${msg}`; } diff --git a/packages/cli/src/lib/help.ts b/packages/cli/src/lib/help.ts index ac4997ec0..a79754dc8 100644 --- a/packages/cli/src/lib/help.ts +++ b/packages/cli/src/lib/help.ts @@ -903,12 +903,12 @@ export function formatHelpHuman(data: HelpJsonResult): string { // Route group if ("commands" in data && "name" in data) { - return formatGroupHuman(data as RouteInfo); + return formatGroupHuman(data); } // Single command if ("path" in data) { - return formatCommandHuman(data as CommandInfo); + return formatCommandHuman(data); } // Error (with optional fuzzy suggestions) diff --git a/packages/cli/src/lib/hex-id-recovery.ts b/packages/cli/src/lib/hex-id-recovery.ts index cb9ee5149..846ac01bb 100644 --- a/packages/cli/src/lib/hex-id-recovery.ts +++ b/packages/cli/src/lib/hex-id-recovery.ts @@ -26,7 +26,6 @@ import { addBreadcrumb } from "@sentry/node"; -import type { SpanListItem } from "../types/index.js"; import { listLogs, listSpans, queryEvents } from "./api-client.js"; import { type LazyCommand, sentry } from "./app-identity.js"; import { @@ -519,7 +518,7 @@ const traceAdapter: FuzzyLookupAdapter = async (ctx) => { statsPeriod: ctx.period ?? SCAN_PERIODS.trace, sort: "date", }); - return (data as SpanListItem[]).map((s) => s.trace); + return data.map((s) => s.trace); }; const logAdapter: FuzzyLookupAdapter = async (ctx) => { @@ -544,7 +543,7 @@ const spanAdapter: FuzzyLookupAdapter = async (ctx) => { statsPeriod: ctx.period ?? SCAN_PERIODS.span, sort: "date", }); - return (data as SpanListItem[]).map((s) => s.id); + return data.map((s) => s.id); }; /** Registry of adapters by entity type. Mutable so tests can stub. */ @@ -571,7 +570,7 @@ async function findTraceBySpanId( query: `id:${spanId}`, statsPeriod: ctx.period ?? SCAN_PERIODS.span, }); - return (data as SpanListItem[])[0]?.trace ?? null; + return data[0]?.trace ?? null; } // --------------------------------------------------------------------------- diff --git a/packages/cli/src/lib/idempotent-operations.ts b/packages/cli/src/lib/idempotent-operations.ts index 474c38929..da775f207 100644 --- a/packages/cli/src/lib/idempotent-operations.ts +++ b/packages/cli/src/lib/idempotent-operations.ts @@ -9,10 +9,7 @@ * request. */ -import { - createIdempotentOperationMatcher, - type IdempotentOperation, -} from "@sentry/api/client"; +import { createIdempotentOperationMatcher } from "@sentry/api/client"; import generated from "../generated/idempotent-operations.json"; /** @@ -22,5 +19,5 @@ import generated from "../generated/idempotent-operations.json"; * @param url - Absolute request URL */ export const isIdempotentOperation = createIdempotentOperationMatcher( - () => generated as IdempotentOperation[], + () => generated, ); diff --git a/packages/cli/src/lib/interactive-login.ts b/packages/cli/src/lib/interactive-login.ts index 21d5655c1..acc378773 100644 --- a/packages/cli/src/lib/interactive-login.ts +++ b/packages/cli/src/lib/interactive-login.ts @@ -47,7 +47,7 @@ export function toLoginUser(user: { }): NonNullable { return Object.fromEntries( Object.entries(user).filter(([k, v]) => k === "id" || Boolean(v)), - ) as NonNullable; + ); } /** Options for the interactive login flow */ @@ -255,7 +255,7 @@ export async function runInteractiveLogin( // Setup keyboard listener for 'c' to copy URL if (process.stdin.isTTY) { keyListener.cleanup = setupCopyKeyListener( - process.stdin as NodeJS.ReadStream & { fd: 0 }, + process.stdin, () => urlToCopy, ); } diff --git a/packages/cli/src/lib/list-command.ts b/packages/cli/src/lib/list-command.ts index 30101e255..fc9a5c113 100644 --- a/packages/cli/src/lib/list-command.ts +++ b/packages/cli/src/lib/list-command.ts @@ -546,7 +546,7 @@ export function buildListCommand< const originalFunc = builderArgs.func; // Auto-inject common flags and aliases into parameters - const params = (builderArgs.parameters ?? {}) as Record; + const params = builderArgs.parameters ?? {}; const existingFlags = (params.flags ?? {}) as Record; const existingAliases = (params.aliases ?? {}) as Record; diff --git a/packages/cli/src/lib/mutate-command.ts b/packages/cli/src/lib/mutate-command.ts index cac7535ac..fd57ae82c 100644 --- a/packages/cli/src/lib/mutate-command.ts +++ b/packages/cli/src/lib/mutate-command.ts @@ -319,7 +319,7 @@ export function buildDeleteCommand< const originalFunc = builderArgs.func; // Auto-inject common flags and aliases into parameters - const params = (builderArgs.parameters ?? {}) as Record; + const params = builderArgs.parameters ?? {}; const existingFlags = (params.flags ?? {}) as Record; const existingAliases = (params.aliases ?? {}) as Record; @@ -366,13 +366,7 @@ export function buildDeleteCommand< const wrappedFunc = function (this: CONTEXT, flags: FLAGS, ...args: any[]) { // Pre-hook: non-interactive safety guard if (!options?.noNonInteractiveGuard) { - guardNonInteractive( - flags as unknown as { - yes?: boolean; - force?: boolean; - "dry-run"?: boolean; - }, - ); + guardNonInteractive(flags); } return originalFunc.call(this, flags, ...(args as unknown as ARGS)); diff --git a/packages/cli/src/lib/positional-parse.ts b/packages/cli/src/lib/positional-parse.ts index 857efa172..89711b7fc 100644 --- a/packages/cli/src/lib/positional-parse.ts +++ b/packages/cli/src/lib/positional-parse.ts @@ -205,7 +205,7 @@ export function skipLeadingArgument

( ): P { const parseAll = typeof positional === "object" && positional !== null - ? argumentParsers.get(positional as object) + ? argumentParsers.get(positional) : undefined; if (!parseAll) { return positional; diff --git a/packages/cli/src/lib/select-ui/ink-ui.ts b/packages/cli/src/lib/select-ui/ink-ui.ts index 625f2fed8..8ecd2ac4b 100644 --- a/packages/cli/src/lib/select-ui/ink-ui.ts +++ b/packages/cli/src/lib/select-ui/ink-ui.ts @@ -66,8 +66,7 @@ async function loadInkApp(): Promise { let isSea = false; // oxlint-disable-next-line sentry-cli/no-silent-catch -- grandfathered silent catch — see #1531; drain by adding log.debug()/log.warn() or re-throwing. try { - // oxlint-disable-next-line typescript/no-explicit-any -- node:sea types not yet in @types/node - const sea = _require("node:sea") as any; + const sea = _require("node:sea"); isSea = sea.isSea?.() === true; } catch { // node:sea not available (older Node or non-SEA context) @@ -76,8 +75,7 @@ async function loadInkApp(): Promise { if (isSea) { // Extract the embedded sidecar to a temp file and import it. // The asset key matches what fossilize registered via --assets. - // oxlint-disable-next-line typescript/no-explicit-any -- node:sea types not yet in @types/node - const sea = _require("node:sea") as any; + const sea = _require("node:sea"); const { writeFileSync, mkdtempSync } = await import("node:fs"); const { tmpdir } = await import("node:os"); const tmpDir = mkdtempSync(join(tmpdir(), "sentry-ink-")); diff --git a/packages/cli/src/lib/sentry-client.ts b/packages/cli/src/lib/sentry-client.ts index 319e1f08b..b9bfe625a 100644 --- a/packages/cli/src/lib/sentry-client.ts +++ b/packages/cli/src/lib/sentry-client.ts @@ -499,10 +499,10 @@ function getAuthenticatedFetch( options.bufferResponseBody || options.idempotent ) { - return createAuthenticatedFetch(options) as unknown as typeof fetch; + return createAuthenticatedFetch(options); } if (!cachedFetch) { - cachedFetch = createAuthenticatedFetch(options) as unknown as typeof fetch; + cachedFetch = createAuthenticatedFetch(options); } return cachedFetch; } diff --git a/packages/cli/src/lib/suppress-sqlite-warning.ts b/packages/cli/src/lib/suppress-sqlite-warning.ts index 4182ac319..78947d881 100644 --- a/packages/cli/src/lib/suppress-sqlite-warning.ts +++ b/packages/cli/src/lib/suppress-sqlite-warning.ts @@ -3,7 +3,7 @@ * module first in each entry point, before anything loads node:sqlite. */ -const originalEmit = process.emit.bind(process) as typeof process.emit; +const originalEmit = process.emit.bind(process); process.emit = ((event: string, ...args: unknown[]) => { if ( event === "warning" && diff --git a/packages/cli/src/lib/time-range.ts b/packages/cli/src/lib/time-range.ts index f800162b7..d852de74a 100644 --- a/packages/cli/src/lib/time-range.ts +++ b/packages/cli/src/lib/time-range.ts @@ -219,7 +219,7 @@ function tryParseOperator(value: string): AbsoluteTimeRange | null { return { type: "absolute", [op.field]: parsed, - } as AbsoluteTimeRange; + }; } return null; diff --git a/packages/cli/test/commands/alert/issues/list.test.ts b/packages/cli/test/commands/alert/issues/list.test.ts index ce5504d90..1f9166007 100644 --- a/packages/cli/test/commands/alert/issues/list.test.ts +++ b/packages/cli/test/commands/alert/issues/list.test.ts @@ -313,7 +313,7 @@ describe("alert issues list pagination", () => { /\/api\/0\/projects\/([^/]+)\/myproj\//, ); if (projectMatch) { - const org = projectMatch[1] as string; + const org = projectMatch[1]; return Response.json({ id: `${org}-id`, slug: "myproj", @@ -444,7 +444,7 @@ describe("alert issues list pagination", () => { /\/api\/0\/organizations\/([^/]+)\/workflows\//, ); if (ruleMatch) { - return Response.json([rule(ruleMatch[1] as string)]); + return Response.json([rule(ruleMatch[1])]); } if (url.pathname === "/api/0/organizations/") { return Response.json([ @@ -456,7 +456,7 @@ describe("alert issues list pagination", () => { /\/api\/0\/projects\/([^/]+)\/myproj\//, ); if (projectMatch) { - const org = projectMatch[1] as string; + const org = projectMatch[1]; return Response.json({ id: `${org}-id`, slug: "myproj", @@ -500,7 +500,7 @@ describe("alert issues list pagination", () => { /\/api\/0\/organizations\/([^/]+)\/workflows\//, ); if (ruleMatch) { - const org = ruleMatch[1] as string; + const org = ruleMatch[1]; if (org === "org-two") { return new Response(JSON.stringify({ detail: "boom" }), { status: 500, @@ -533,7 +533,7 @@ describe("alert issues list pagination", () => { /\/api\/0\/projects\/([^/]+)\/myproj\//, ); if (projectMatch) { - const org = projectMatch[1] as string; + const org = projectMatch[1]; return Response.json({ id: `${org}-id`, slug: "myproj", @@ -641,7 +641,7 @@ describe("alert issues list pagination", () => { /\/api\/0\/organizations\/([^/]+)\/workflows\//, ); if (ruleMatch) { - const org = ruleMatch[1] as string; + const org = ruleMatch[1]; const perPage = Number(url.searchParams.get("per_page")); perPageByOrg.set(org, perPage); return new Response( @@ -670,7 +670,7 @@ describe("alert issues list pagination", () => { /\/api\/0\/projects\/([^/]+)\/myproj\//, ); if (projectMatch) { - const org = projectMatch[1] as string; + const org = projectMatch[1]; return Response.json({ id: `${org}-id`, slug: "myproj", diff --git a/packages/cli/test/commands/alert/metrics/list.test.ts b/packages/cli/test/commands/alert/metrics/list.test.ts index 633f8b05e..7aee9f680 100644 --- a/packages/cli/test/commands/alert/metrics/list.test.ts +++ b/packages/cli/test/commands/alert/metrics/list.test.ts @@ -325,7 +325,7 @@ describe("alert metrics list pagination", () => { /\/api\/0\/projects\/([^/]+)\/myproj\//, ); if (projectMatch) { - const org = projectMatch[1] as string; + const org = projectMatch[1]; return Response.json({ id: `${org}-id`, slug: "myproj", @@ -424,7 +424,7 @@ describe("alert metrics list pagination", () => { /\/api\/0\/organizations\/([^/]+)\/detectors\//, ); if (alertMatch) { - return Response.json([rule(alertMatch[1] as string)]); + return Response.json([rule(alertMatch[1])]); } if (url.pathname === "/api/0/organizations/") { return Response.json([ @@ -436,7 +436,7 @@ describe("alert metrics list pagination", () => { /\/api\/0\/projects\/([^/]+)\/myproj\//, ); if (projectMatch) { - const org = projectMatch[1] as string; + const org = projectMatch[1]; return Response.json({ id: `${org}-id`, slug: "myproj", @@ -481,7 +481,7 @@ describe("alert metrics list pagination", () => { /\/api\/0\/organizations\/([^/]+)\/detectors\//, ); if (alertMatch) { - const org = alertMatch[1] as string; + const org = alertMatch[1]; if (org === "org-two") { return new Response(JSON.stringify({ detail: "boom" }), { status: 500, @@ -505,7 +505,7 @@ describe("alert metrics list pagination", () => { /\/api\/0\/projects\/([^/]+)\/myproj\//, ); if (projectMatch) { - const org = projectMatch[1] as string; + const org = projectMatch[1]; return Response.json({ id: `${org}-id`, slug: "myproj", @@ -594,7 +594,7 @@ describe("alert metrics list pagination", () => { /\/api\/0\/organizations\/([^/]+)\/detectors\//, ); if (alertMatch) { - const org = alertMatch[1] as string; + const org = alertMatch[1]; const perPage = Number(url.searchParams.get("per_page")); perPageByOrg.set(org, perPage); return new Response( @@ -623,7 +623,7 @@ describe("alert metrics list pagination", () => { /\/api\/0\/projects\/([^/]+)\/myproj\//, ); if (projectMatch) { - const org = projectMatch[1] as string; + const org = projectMatch[1]; return Response.json({ id: `${org}-id`, slug: "myproj", diff --git a/packages/cli/test/commands/api.property.test.ts b/packages/cli/test/commands/api.property.test.ts index 2fe8f569a..2fe617270 100644 --- a/packages/cli/test/commands/api.property.test.ts +++ b/packages/cli/test/commands/api.property.test.ts @@ -241,9 +241,7 @@ describe("parseMethod properties", () => { property(validMethodArb, (method) => { const result = parseMethod(method); expect(result).toBe(method.toUpperCase() as typeof result); - expect(["GET", "POST", "PUT", "DELETE", "PATCH"]).toContain( - result as string, - ); + expect(["GET", "POST", "PUT", "DELETE", "PATCH"]).toContain(result); }), { numRuns: DEFAULT_NUM_RUNS }, ); @@ -535,11 +533,11 @@ const bareFieldArb = stringMatching(/^[a-zA-Z][a-zA-Z0-9]{1,15}$/).filter( function captureStderr(fn: () => void): string { let output = ""; const original = process.stderr.write; - process.stderr.write = ((chunk: string | Uint8Array) => { + process.stderr.write = (chunk: string | Uint8Array) => { output += typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk); return true; - }) as typeof process.stderr.write; + }; try { fn(); } finally { @@ -772,7 +770,7 @@ describe("property: buildFromFields", () => { }); }); -const MOCK_STDIN = process.stdin as unknown as NodeJS.ReadStream & { fd: 0 }; +const MOCK_STDIN = process.stdin; describe("property: resolveBody", () => { test("--data always returns a body (no params)", async () => { diff --git a/packages/cli/test/commands/api.test.ts b/packages/cli/test/commands/api.test.ts index d0d82802f..3e09f46e3 100644 --- a/packages/cli/test/commands/api.test.ts +++ b/packages/cli/test/commands/api.test.ts @@ -449,11 +449,11 @@ describe("normalizeFields", () => { beforeEach(() => { stderrOutput = ""; originalWrite = process.stderr.write; - process.stderr.write = ((chunk: string | Uint8Array) => { + process.stderr.write = (chunk: string | Uint8Array) => { stderrOutput += typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk); return true; - }) as typeof process.stderr.write; + }; }); afterEach(() => { @@ -1265,11 +1265,11 @@ describe("resolveBinaryTtyOutput", () => { beforeEach(() => { stderrOutput = ""; originalWrite = process.stderr.write; - process.stderr.write = ((chunk: string | Uint8Array) => { + process.stderr.write = (chunk: string | Uint8Array) => { stderrOutput += typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk); return true; - }) as typeof process.stderr.write; + }; }); afterEach(() => { @@ -1423,11 +1423,11 @@ describe("extractJsonBody", () => { beforeEach(() => { stderrOutput = ""; originalWrite = process.stderr.write; - process.stderr.write = ((chunk: string | Uint8Array) => { + process.stderr.write = (chunk: string | Uint8Array) => { stderrOutput += typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk); return true; - }) as typeof process.stderr.write; + }; }); afterEach(() => { @@ -1521,11 +1521,11 @@ describe("buildFromFields", () => { beforeEach(() => { stderrOutput = ""; originalWrite = process.stderr.write; - process.stderr.write = ((chunk: string | Uint8Array) => { + process.stderr.write = (chunk: string | Uint8Array) => { stderrOutput += typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk); return true; - }) as typeof process.stderr.write; + }; }); afterEach(() => { @@ -1621,7 +1621,7 @@ describe("buildFromFields", () => { // This was extracted from the Stricli command handler (func) so that // --data, --input, and field flag mutual-exclusivity logic can be unit-tested. -const MOCK_STDIN = process.stdin as unknown as NodeJS.ReadStream & { fd: 0 }; +const MOCK_STDIN = process.stdin; describe("resolveBody", () => { test("--data returns parsed JSON body", async () => { diff --git a/packages/cli/test/commands/attribute/list.test.ts b/packages/cli/test/commands/attribute/list.test.ts index f18419744..bcc799b1b 100644 --- a/packages/cli/test/commands/attribute/list.test.ts +++ b/packages/cli/test/commands/attribute/list.test.ts @@ -266,7 +266,7 @@ describe("fetchAttributeTypePage", () => { listSpy.mockImplementation(async (_org, options) => { const page = pages[options.cursor ?? "first"]; expect(page).toBeDefined(); - return page!; + return page; }); const page = await fetchAttributeTypePage( @@ -513,7 +513,7 @@ describe("listCommand.func", () => { expect(options.perPage).toBe(2); const page = pages[options.cursor ?? "first"]; expect(page).toBeDefined(); - return page!; + return page; }); const collected: string[] = []; for (let index = 0; index < 5; index++) { @@ -589,7 +589,7 @@ describe("listCommand.func", () => { expect(collected).toEqual(data.map((row) => row.key)); expect(cursorLengths.length).toBeGreaterThan(10); // Cursor stops growing once paging reaches a steady state - expect(Math.max(...cursorLengths) - cursorLengths[0]!).toBeLessThan(64); + expect(Math.max(...cursorLengths) - cursorLengths[0]).toBeLessThan(64); }); test("continues mixed types past 100 rows without losing partially selected pages", async () => { diff --git a/packages/cli/test/commands/auth/default.test.ts b/packages/cli/test/commands/auth/default.test.ts index 82f13341d..d63fdef52 100644 --- a/packages/cli/test/commands/auth/default.test.ts +++ b/packages/cli/test/commands/auth/default.test.ts @@ -77,7 +77,7 @@ describe("authDefaultCommand", () => { try { const func = await authDefaultCommand.loader(); - await func.call(context as never, { + await func.call(context, { timeout: 900, force: false, "read-only": false, @@ -128,7 +128,7 @@ describe("authDefaultCommand", () => { try { const func = await authDefaultCommand.loader(); - await func.call(context as never, { + await func.call(context, { timeout: 900, force: false, "read-only": false, diff --git a/packages/cli/test/commands/auth/status.test.ts b/packages/cli/test/commands/auth/status.test.ts index 8c4a9ced6..5d5744e6c 100644 --- a/packages/cli/test/commands/auth/status.test.ts +++ b/packages/cli/test/commands/auth/status.test.ts @@ -301,7 +301,7 @@ describe("statusCommand.func", () => { id: "7", name: "CI Bot", email: "ci@example.com", - } as Awaited>); + }); try { const { context, getOutput } = createContext(); diff --git a/packages/cli/test/commands/auth/switch.test.ts b/packages/cli/test/commands/auth/switch.test.ts index 09ef25024..47e9f0c61 100644 --- a/packages/cli/test/commands/auth/switch.test.ts +++ b/packages/cli/test/commands/auth/switch.test.ts @@ -142,7 +142,7 @@ describe("auth list", () => { await resetHostScopingState(); requests = []; originalFetch = globalThis.fetch; - globalThis.fetch = (async ( + globalThis.fetch = async ( input: RequestInfo | URL, init?: RequestInit, ) => { @@ -158,7 +158,7 @@ describe("auth list", () => { }); } return Response.json({ detail: "Invalid token" }, { status: 401 }); - }) as typeof globalThis.fetch; + }; }); afterEach(async () => { diff --git a/packages/cli/test/commands/bash-hook.test.ts b/packages/cli/test/commands/bash-hook.test.ts index 6884a78c2..907f3e28d 100644 --- a/packages/cli/test/commands/bash-hook.test.ts +++ b/packages/cli/test/commands/bash-hook.test.ts @@ -25,7 +25,7 @@ async function runBashHook( process: { ...process, exitCode: undefined, - } as typeof process, + }, env: process.env, cwd: process.cwd(), homeDir: "/tmp", diff --git a/packages/cli/test/commands/build/upload.test.ts b/packages/cli/test/commands/build/upload.test.ts index 5bcb83999..69b838a81 100644 --- a/packages/cli/test/commands/build/upload.test.ts +++ b/packages/cli/test/commands/build/upload.test.ts @@ -69,8 +69,8 @@ async function runViaApp( ): Promise<{ stderr: string; exitCode: number | undefined }> { let stderr = ""; const context: SentryContext = { - process: { ...process, exitCode: undefined } as typeof process, - env: {} as NodeJS.ProcessEnv, + process: { ...process, exitCode: undefined }, + env: {}, cwd: tmpDir, homeDir: tmpDir, configDir: tmpDir, @@ -299,7 +299,7 @@ describe("build upload", () => { "archive.xcarchive/dSYMs/Framework.dSYM/Contents/symbols" ], ).toEqual(strToU8("framework symbols")); - expect(existsSync(uploads[0]!.path)).toBe(false); + expect(existsSync(uploads[0].path)).toBe(false); }); test.each(["apk", "aab", "xcarchive"])( diff --git a/packages/cli/test/commands/cli.test.ts b/packages/cli/test/commands/cli.test.ts index df97de88a..b9980c412 100644 --- a/packages/cli/test/commands/cli.test.ts +++ b/packages/cli/test/commands/cli.test.ts @@ -31,10 +31,10 @@ function createMockContext(overrides: Partial<{ execPath: string }> = {}): { // Capture logger output (routed to process.stderr) const origWrite = process.stderr.write.bind(process.stderr); - process.stderr.write = ((chunk: string | Uint8Array) => { + process.stderr.write = (chunk: string | Uint8Array) => { stderrChunks.push(String(chunk)); return true; - }) as typeof process.stderr.write; + }; const context = { process: { execPath: overrides.execPath ?? "/test/path/sentry" }, @@ -124,11 +124,11 @@ describe("upgradeCommand.func", () => { // indirectly through the upgrade.ts unit tests in lib/upgrade.test.ts. test("shows installation info with specified method", async () => { - globalThis.fetch = (async () => + globalThis.fetch = async () => new Response(JSON.stringify([{ tag_name: "cli@1.0.0" }]), { status: 200, headers: { "Content-Type": "application/json" }, - })) as typeof fetch; + }); const func = await upgradeCommand.loader(); const { context, getStdout, restore } = createMockContext(); @@ -146,11 +146,11 @@ describe("upgradeCommand.func", () => { test("check mode shows update available", async () => { // Curl uses the Toolkit GitHub release list with product-prefixed tags. - globalThis.fetch = (async () => + globalThis.fetch = async () => new Response(JSON.stringify([{ tag_name: "cli@99.0.0" }]), { status: 200, headers: { "Content-Type": "application/json" }, - })) as typeof fetch; + }); const func = await upgradeCommand.loader(); const { context, getStdout, restore } = createMockContext(); @@ -165,7 +165,7 @@ describe("upgradeCommand.func", () => { }); test("check mode with version shows versioned command", async () => { - globalThis.fetch = (async (url) => { + globalThis.fetch = async (url) => { const response = extractInputUrl(url).includes( "/releases/tags/cli%402.0.0", ) @@ -175,7 +175,7 @@ describe("upgradeCommand.func", () => { status: 200, headers: { "Content-Type": "application/json" }, }); - }) as typeof fetch; + }; const func = await upgradeCommand.loader(); const { context, getStdout, restore } = createMockContext(); @@ -195,11 +195,11 @@ describe("upgradeCommand.func", () => { }); test("check mode compares the current version with a stable target", async () => { - globalThis.fetch = (async () => + globalThis.fetch = async () => new Response(JSON.stringify([{ tag_name: "cli@1.0.0" }]), { status: 200, headers: { "Content-Type": "application/json" }, - })) as typeof fetch; + }); const func = await upgradeCommand.loader(); const { context, getStdout, restore } = createMockContext(); @@ -215,10 +215,10 @@ describe("upgradeCommand.func", () => { test("throws UpgradeError when specified version does not exist", async () => { let callCount = 0; - globalThis.fetch = (async () => { + globalThis.fetch = async () => { callCount += 1; return new Response("Not Found", { status: 404 }); - }) as typeof fetch; + }; const func = await upgradeCommand.loader(); const { context, restore } = createMockContext(); diff --git a/packages/cli/test/commands/cli/completion.test.ts b/packages/cli/test/commands/cli/completion.test.ts index 489c65a6f..b817254c1 100644 --- a/packages/cli/test/commands/cli/completion.test.ts +++ b/packages/cli/test/commands/cli/completion.test.ts @@ -26,7 +26,7 @@ async function runCompletion( process: { ...process, exitCode: undefined, - } as typeof process, + }, env, cwd: process.cwd(), homeDir: "/tmp", diff --git a/packages/cli/test/commands/cli/fix.test.ts b/packages/cli/test/commands/cli/fix.test.ts index 6dd5ec002..ea5a84c4b 100644 --- a/packages/cli/test/commands/cli/fix.test.ts +++ b/packages/cli/test/commands/cli/fix.test.ts @@ -38,7 +38,7 @@ function createPreMigrationDatabase(db: Database): void { if (preMigrationTables.includes(tableName)) { statements.push(generatePreMigrationTableDDL(tableName)); } else { - statements.push(EXPECTED_TABLES[tableName] as string); + statements.push(EXPECTED_TABLES[tableName]); } } @@ -61,7 +61,7 @@ function createDatabaseWithMissingTables( for (const tableName of Object.keys(EXPECTED_TABLES)) { if (missingTables.includes(tableName)) continue; - statements.push(EXPECTED_TABLES[tableName] as string); + statements.push(EXPECTED_TABLES[tableName]); } db.exec(statements.join(";\n")); diff --git a/packages/cli/test/commands/cli/setup.test.ts b/packages/cli/test/commands/cli/setup.test.ts index f8057fa75..2c17ca587 100644 --- a/packages/cli/test/commands/cli/setup.test.ts +++ b/packages/cli/test/commands/cli/setup.test.ts @@ -96,7 +96,7 @@ let originalFetch: typeof globalThis.fetch; function mockFetch( fn: (url: string | URL | Request, init?: RequestInit) => Promise, ): void { - globalThis.fetch = fn as typeof globalThis.fetch; + globalThis.fetch = fn; } /** @@ -120,10 +120,10 @@ function createMockContext( } { const stderrChunks: string[] = []; const origWrite = process.stderr.write.bind(process.stderr); - process.stderr.write = ((chunk: string | Uint8Array) => { + process.stderr.write = (chunk: string | Uint8Array) => { stderrChunks.push(String(chunk)); return true; - }) as typeof process.stderr.write; + }; const env: Record = { PATH: "/usr/bin:/bin", diff --git a/packages/cli/test/commands/cli/uninstall.test.ts b/packages/cli/test/commands/cli/uninstall.test.ts index ab5abf4d9..d8dee56bd 100644 --- a/packages/cli/test/commands/cli/uninstall.test.ts +++ b/packages/cli/test/commands/cli/uninstall.test.ts @@ -57,7 +57,7 @@ async function runUninstall( process: { ...process, exitCode: undefined, - } as typeof process, + }, env: process.env, cwd: process.cwd(), homeDir: "/tmp", diff --git a/packages/cli/test/commands/cli/upgrade.test.ts b/packages/cli/test/commands/cli/upgrade.test.ts index 7f94e8fc9..a811ad6cc 100644 --- a/packages/cli/test/commands/cli/upgrade.test.ts +++ b/packages/cli/test/commands/cli/upgrade.test.ts @@ -81,7 +81,7 @@ let originalFetch: typeof globalThis.fetch; function mockFetch( fn: (url: string | URL | Request, init?: RequestInit) => Promise, ): void { - globalThis.fetch = fn as typeof globalThis.fetch; + globalThis.fetch = fn; } /** @@ -123,17 +123,17 @@ function createMockContext( // Capture logger output (routed to process.stderr) const origStderrWrite = process.stderr.write.bind(process.stderr); - process.stderr.write = ((chunk: string | Uint8Array) => { + process.stderr.write = (chunk: string | Uint8Array) => { stderrChunks.push(String(chunk)); return true; - }) as typeof process.stderr.write; + }; // Capture spinner output (routed to process.stdout) const origStdoutWrite = process.stdout.write.bind(process.stdout); - process.stdout.write = ((chunk: string | Uint8Array) => { + process.stdout.write = (chunk: string | Uint8Array) => { stdoutChunks.push(String(chunk)); return true; - }) as typeof process.stdout.write; + }; const stdoutWriter = { write: (s: string) => { @@ -879,7 +879,7 @@ function fakeChildProcess(exitCode: number): child_process.ChildProcess { const emitter = new EventEmitter(); // Emit "close" asynchronously so the caller can attach listeners first queueMicrotask(() => emitter.emit("close", exitCode)); - return emitter as unknown as child_process.ChildProcess; + return emitter; } /** diff --git a/packages/cli/test/commands/dart-symbol-map/upload.test.ts b/packages/cli/test/commands/dart-symbol-map/upload.test.ts index c6317149a..37a74009f 100644 --- a/packages/cli/test/commands/dart-symbol-map/upload.test.ts +++ b/packages/cli/test/commands/dart-symbol-map/upload.test.ts @@ -38,7 +38,7 @@ async function runUpload( process: { ...process, exitCode: undefined, - } as typeof process, + }, env: process.env, cwd: process.cwd(), homeDir: "/tmp", diff --git a/packages/cli/test/commands/dashboard/list.test.ts b/packages/cli/test/commands/dashboard/list.test.ts index 90fd2d317..75b2b4528 100644 --- a/packages/cli/test/commands/dashboard/list.test.ts +++ b/packages/cli/test/commands/dashboard/list.test.ts @@ -172,7 +172,7 @@ describe("dashboard list command", () => { const hasPreviousPageSpy = vi.mocked(paginationDb.hasPreviousPage); beforeEach(() => { - openInBrowserSpy.mockResolvedValue(undefined as never); + openInBrowserSpy.mockResolvedValue(undefined); // Bypass spinner — just run the callback directly withProgressSpy.mockImplementation((_opts, fn) => fn(() => { diff --git a/packages/cli/test/commands/dashboard/widget/preservation.test.ts b/packages/cli/test/commands/dashboard/widget/preservation.test.ts index e57fc4270..55ec46e98 100644 --- a/packages/cli/test/commands/dashboard/widget/preservation.test.ts +++ b/packages/cli/test/commands/dashboard/widget/preservation.test.ts @@ -147,13 +147,13 @@ test.each([ const reload = await ctx.run(["api", endpoint]); expect(reload.exitCode, reload.stderr).toBe(0); const expected = structuredClone(savedDashboard); - const transformed = expected.widgets![0]!; + const transformed = expected.widgets![0]; if (name === "rename") { transformed.title = "Renamed"; } else if (name === "move") { transformed.layout!.y = 4; } else if (name === "filter") { - transformed.queries![0]!.conditions = "span.op:queue"; + transformed.queries![0].conditions = "span.op:queue"; } else if (name === "delete another widget") { expected.widgets!.splice(1, 1); } diff --git a/packages/cli/test/commands/debug-files/bundle-sources.test.ts b/packages/cli/test/commands/debug-files/bundle-sources.test.ts index c25726c38..fd785697e 100644 --- a/packages/cli/test/commands/debug-files/bundle-sources.test.ts +++ b/packages/cli/test/commands/debug-files/bundle-sources.test.ts @@ -51,7 +51,7 @@ async function runBundleSources( ): Promise<{ output: string; exitCode: number | undefined }> { let output = ""; const mockContext: SentryContext = { - process: { ...process, exitCode: undefined } as typeof process, + process: { ...process, exitCode: undefined }, env: process.env, cwd: process.cwd(), homeDir: "/tmp", diff --git a/packages/cli/test/commands/debug-files/check.test.ts b/packages/cli/test/commands/debug-files/check.test.ts index 46cbf0a41..9184d88ce 100644 --- a/packages/cli/test/commands/debug-files/check.test.ts +++ b/packages/cli/test/commands/debug-files/check.test.ts @@ -41,7 +41,7 @@ async function runCheck( ): Promise<{ output: string; exitCode: number | undefined }> { let output = ""; const mockContext: SentryContext = { - process: { ...process, exitCode: undefined } as typeof process, + process: { ...process, exitCode: undefined }, env: process.env, cwd: process.cwd(), homeDir: "/tmp", diff --git a/packages/cli/test/commands/debug-files/find.test.ts b/packages/cli/test/commands/debug-files/find.test.ts index d03d883e8..3594f156d 100644 --- a/packages/cli/test/commands/debug-files/find.test.ts +++ b/packages/cli/test/commands/debug-files/find.test.ts @@ -40,7 +40,7 @@ async function runFind( ): Promise<{ output: string; exitCode: number | undefined }> { let output = ""; const mockContext: SentryContext = { - process: { ...process, exitCode: undefined } as typeof process, + process: { ...process, exitCode: undefined }, env: process.env, cwd: process.cwd(), homeDir: "/tmp", diff --git a/packages/cli/test/commands/debug-files/print-sources.test.ts b/packages/cli/test/commands/debug-files/print-sources.test.ts index db4e85c1e..44f04351a 100644 --- a/packages/cli/test/commands/debug-files/print-sources.test.ts +++ b/packages/cli/test/commands/debug-files/print-sources.test.ts @@ -54,7 +54,7 @@ async function runPrintSources( ): Promise<{ output: string; exitCode: number | undefined }> { let output = ""; const mockContext: SentryContext = { - process: { ...process, exitCode: undefined } as typeof process, + process: { ...process, exitCode: undefined }, env: process.env, cwd: process.cwd(), homeDir: "/tmp", diff --git a/packages/cli/test/commands/debug-files/upload.test.ts b/packages/cli/test/commands/debug-files/upload.test.ts index fe22a10b7..e57199b52 100644 --- a/packages/cli/test/commands/debug-files/upload.test.ts +++ b/packages/cli/test/commands/debug-files/upload.test.ts @@ -59,7 +59,7 @@ beforeEach(async () => { hashAlgorithm: "sha1", concurrency: 8, compression: ["gzip"], - } as Awaited>); + }); }); afterEach(async () => { @@ -128,7 +128,7 @@ async function runUpload( let output = ""; let error = ""; const mockContext: SentryContext = { - process: { ...process, exitCode: undefined } as typeof process, + process: { ...process, exitCode: undefined }, env: process.env, cwd: tempDir, homeDir: "/tmp", @@ -375,7 +375,7 @@ describe("sentry debug-files upload", () => { hashAlgorithm: "sha1", concurrency: 8, compression: ["gzip"], - } as Awaited>); + }); const spy = vi.spyOn(debugFilesApi, "uploadDebugFiles"); const { exitCode } = await runUpload([tempDir]); @@ -408,7 +408,7 @@ describe("sentry debug-files upload", () => { hashAlgorithm: "sha1", concurrency: 8, compression: ["gzip"], - } as Awaited>); + }); const spy = vi.spyOn(debugFilesApi, "uploadDebugFiles").mockResolvedValue([ { diff --git a/packages/cli/test/commands/event/view.test.ts b/packages/cli/test/commands/event/view.test.ts index fae4ff8cf..efc1ee6a3 100644 --- a/packages/cli/test/commands/event/view.test.ts +++ b/packages/cli/test/commands/event/view.test.ts @@ -1115,7 +1115,7 @@ describe("viewCommand.func", () => { title: "Error: test", metadata: {}, contexts: {}, - } as unknown as SentryEvent; + }; const attachment = { id: "attachment-1", event_id: VALID_EVENT_ID, @@ -1317,7 +1317,7 @@ describe("viewCommand.func", () => { .mockResolvedValue(sampleEvent); getIssueInOrgSpy.mockResolvedValue({ project: { slug: "auto-project" }, - } as never); + }); getSpanTreeLinesSpy.mockResolvedValue({ lines: [], spans: null, @@ -1464,7 +1464,7 @@ describe("viewCommand.func", () => { test("a selector fails when no unresolved issue matches", async () => { const listIssuesSpy = vi .spyOn(apiClient, "listIssuesPaginated") - .mockResolvedValue({ data: [] } as never); + .mockResolvedValue({ data: [] }); const getLatestEventSpy = vi.spyOn(apiClient, "getLatestEvent"); const { context } = createMockContext(); @@ -1596,7 +1596,7 @@ describe("fetchEventWithContext", () => { tags: [], dateCreated: "2026-01-01T00:00:00Z", dateReceived: "2026-01-01T00:00:00Z", - } as unknown as SentryEvent; + }; afterEach(() => { vi.restoreAllMocks(); diff --git a/packages/cli/test/commands/games/snake.test.ts b/packages/cli/test/commands/games/snake.test.ts index 616bbb8d8..a5a0c50da 100644 --- a/packages/cli/test/commands/games/snake.test.ts +++ b/packages/cli/test/commands/games/snake.test.ts @@ -17,7 +17,7 @@ function createContext(isTTY: boolean) { async function run(isTTY: boolean): Promise { const func = await snakeCommand.loader(); - await func.call(createContext(isTTY) as never, {}); + await func.call(createContext(isTTY), {}); } describe("games snake", () => { diff --git a/packages/cli/test/commands/info.test.ts b/packages/cli/test/commands/info.test.ts index dff0f91d9..e0d3e1fe6 100644 --- a/packages/cli/test/commands/info.test.ts +++ b/packages/cli/test/commands/info.test.ts @@ -64,7 +64,7 @@ describe("sentry info", () => { id: "1", email: "me@example.com", name: "Me", - } as Awaited>); + }); vi.spyOn(defaults, "getDefaultOrganization").mockReturnValue("acme"); vi.spyOn(defaults, "getDefaultProject").mockReturnValue("web"); @@ -103,7 +103,7 @@ describe("sentry info", () => { vi.spyOn(users, "getCurrentUser").mockResolvedValue({ id: "1", email: "me@example.com", - } as Awaited>); + }); const harness = createContext(); const func = await infoCommand.loader(); diff --git a/packages/cli/test/commands/issue/list.property.test.ts b/packages/cli/test/commands/issue/list.property.test.ts index 2719ede0a..12467987e 100644 --- a/packages/cli/test/commands/issue/list.property.test.ts +++ b/packages/cli/test/commands/issue/list.property.test.ts @@ -96,18 +96,15 @@ const sentryIssueArb = tuple( isoDateArb, nat({ max: 100_000 }), nat({ max: 50_000 }), -).map( - ([lastSeen, firstSeen, count, userCount]) => - ({ - id: `${Math.random()}`, - shortId: "PROJ-1", - title: "test", - lastSeen, - firstSeen, - count: `${count}`, - userCount, - }) as SentryIssue, -); +).map(([lastSeen, firstSeen, count, userCount]) => ({ + id: `${Math.random()}`, + shortId: "PROJ-1", + title: "test", + lastSeen, + firstSeen, + count: `${count}`, + userCount, +})); // --- trimWithProjectGuarantee --- diff --git a/packages/cli/test/commands/issue/list.test.ts b/packages/cli/test/commands/issue/list.test.ts index 425ca92c7..9f9dbe557 100644 --- a/packages/cli/test/commands/issue/list.test.ts +++ b/packages/cli/test/commands/issue/list.test.ts @@ -1007,7 +1007,7 @@ describe("issue list: org-all mode (cursor pagination)", () => { id: "1", slug: "test-project", name: "Test Project", - } as Awaited>); + }); const { context } = createOrgAllContext(); @@ -1544,10 +1544,7 @@ describe("issue list: collapse parameter optimization", () => { const { context } = createOrgAllContext(); await orgAllFunc.call(context, callFlags, "my-org/"); - return (listIssuesAllPagesMock.mock.calls[0]?.[2] ?? {}) as Record< - string, - unknown - >; + return listIssuesAllPagesMock.mock.calls[0]?.[2] ?? {}; } beforeEach(async () => { @@ -1601,10 +1598,7 @@ describe("issue list: collapse parameter optimization", () => { { limit: 10, period: parsePeriod("90d"), json: true }, "my-org/", ); - return (listIssuesAllPagesMock.mock.calls[0]?.[2] ?? {}) as Record< - string, - unknown - >; + return listIssuesAllPagesMock.mock.calls[0]?.[2] ?? {}; } test("uses recommended on Sentry SaaS", async () => { @@ -2310,7 +2304,7 @@ describe("issue list: comma-separated project slugs", () => { if (slug === "api") { throw new ApiError("Forbidden", 403); } - return catalog[0] as (typeof catalog)[number]; + return catalog[0]; }); const error = await func diff --git a/packages/cli/test/commands/issue/plan.func.test.ts b/packages/cli/test/commands/issue/plan.func.test.ts index 16cfa4dac..03f0de54f 100644 --- a/packages/cli/test/commands/issue/plan.func.test.ts +++ b/packages/cli/test/commands/issue/plan.func.test.ts @@ -175,7 +175,7 @@ describe("issue plan after solution planning", () => { solution: [{ title: "Fix it", code_snippet_and_analysis: "do x" }], }, ], - } as AutofixState); + }); await runPlan(createMockContext()); @@ -222,7 +222,7 @@ describe("issue plan after solution planning", () => { solution: [{ title: "Fix it", code_snippet_and_analysis: "do x" }], }, ], - } as AutofixState); + }); const context = createMockContext(); await runPlan(context); diff --git a/packages/cli/test/commands/issue/resolve-commit-spec.test.ts b/packages/cli/test/commands/issue/resolve-commit-spec.test.ts index ded2cae14..9e4f71372 100644 --- a/packages/cli/test/commands/issue/resolve-commit-spec.test.ts +++ b/packages/cli/test/commands/issue/resolve-commit-spec.test.ts @@ -23,7 +23,7 @@ function makeRepo(overrides: Partial): SentryRepository { status: "active", externalSlug: "getsentry/cli", ...overrides, - } as SentryRepository; + }; } describe("resolveCommitSpec — explicit mode", () => { diff --git a/packages/cli/test/commands/issue/tags.test.ts b/packages/cli/test/commands/issue/tags.test.ts index fee2d6c8f..3c8b0ba95 100644 --- a/packages/cli/test/commands/issue/tags.test.ts +++ b/packages/cli/test/commands/issue/tags.test.ts @@ -210,7 +210,7 @@ describe("sentry issue tags", () => { tagResponse = { ...TAG, key: "\u001b[2Jrelease\u202e", - topValues: [{ ...TAG.topValues![0]!, value }], + topValues: [{ ...TAG.topValues![0], value }], }; const args = ["issue", "tags", "test-org/12345", "release"]; const human = await runCli(args); diff --git a/packages/cli/test/commands/issue/utils.test.ts b/packages/cli/test/commands/issue/utils.test.ts index 11d125a3b..0637726c9 100644 --- a/packages/cli/test/commands/issue/utils.test.ts +++ b/packages/cli/test/commands/issue/utils.test.ts @@ -1293,10 +1293,10 @@ describe("pollAutofixState", () => { // Spy on process.stdout.write to capture spinner output const origWrite = process.stdout.write.bind(process.stdout); - process.stdout.write = ((chunk: string | Uint8Array) => { + process.stdout.write = (chunk: string | Uint8Array) => { stdoutOutput += String(chunk); return true; - }) as typeof process.stdout.write; + }; try { // Return PROCESSING first to allow animation interval to fire, @@ -1749,10 +1749,10 @@ describe("ensureRootCauseAnalysis", () => { // Spy on process.stdout.write to capture spinner output const origWrite = process.stdout.write.bind(process.stdout); - process.stdout.write = ((chunk: string | Uint8Array) => { + process.stdout.write = (chunk: string | Uint8Array) => { stdoutOutput += String(chunk); return true; - }) as typeof process.stdout.write; + }; try { // @ts-expect-error - partial mock diff --git a/packages/cli/test/commands/local/control-plane.test.ts b/packages/cli/test/commands/local/control-plane.test.ts index f139a49e8..3fbe832a6 100644 --- a/packages/cli/test/commands/local/control-plane.test.ts +++ b/packages/cli/test/commands/local/control-plane.test.ts @@ -89,7 +89,7 @@ describe("Local control plane", () => { try { const chunk = new TextDecoder().decode((await reader.read()).value); expect(chunk).toContain("event: sentry.local.directory"); - const data = JSON.parse(chunk.match(/data: (.+)/)![1]!); + const data = JSON.parse(chunk.match(/data: (.+)/)![1]); expect(new URL(data.directoryUrl).pathname).toBe( "/_local/v1/ui/sessions", ); diff --git a/packages/cli/test/commands/local/server.test.ts b/packages/cli/test/commands/local/server.test.ts index a1fc1c7a2..c71e69516 100644 --- a/packages/cli/test/commands/local/server.test.ts +++ b/packages/cli/test/commands/local/server.test.ts @@ -295,7 +295,7 @@ describe("sentry local serve --open", () => { signal.trigger(); await command; expectViewerHint(); - const url = new URL(opener.mock.calls[0]![0]); + const url = new URL(opener.mock.calls[0][0]); expect(new URLSearchParams(url.hash.slice(1)).get("directory")).toBe( directoryUrl, ); diff --git a/packages/cli/test/commands/local/session-snapshot.test.ts b/packages/cli/test/commands/local/session-snapshot.test.ts index 4779575db..0f169d0a9 100644 --- a/packages/cli/test/commands/local/session-snapshot.test.ts +++ b/packages/cli/test/commands/local/session-snapshot.test.ts @@ -40,9 +40,7 @@ describe("Local session snapshot", () => { const session = store.create({ label: "web", cwd: "/work/web" }); const capabilities = store.getCapabilities(session.id); // A caller passing the stored session still writes no capability - writeLocalSessionSnapshot(process.pid, [ - { ...session, ...capabilities } as LocalSession, - ]); + writeLocalSessionSnapshot(process.pid, [{ ...session, ...capabilities }]); const path = join(getConfigDir(), LOCAL_SESSION_SNAPSHOT_FILENAME); const text = await readFile(path, "utf8"); diff --git a/packages/cli/test/commands/org/list.test.ts b/packages/cli/test/commands/org/list.test.ts index d335b119f..10b8104d3 100644 --- a/packages/cli/test/commands/org/list.test.ts +++ b/packages/cli/test/commands/org/list.test.ts @@ -74,7 +74,7 @@ beforeEach(async () => { usersByToken = {}; requests = []; originalFetch = globalThis.fetch; - globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => { + globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit) => { const req = new Request(input, init); const url = new URL(req.url); const token = req.headers.get("Authorization")?.replace(/^Bearer /, ""); @@ -101,7 +101,7 @@ beforeEach(async () => { links: { organizationUrl: o.regionUrl, regionUrl: o.regionUrl }, })), ); - }) as typeof globalThis.fetch; + }; }); afterEach(() => { @@ -159,7 +159,7 @@ async function runListHuman(filter?: string): Promise { function slugsWithAccount(entries: Record[]): string[][] { return entries.map((e) => [ e.slug as string, - ((e.account as { email?: string } | undefined)?.email ?? "") as string, + (e.account as { email?: string } | undefined)?.email ?? "", ]); } diff --git a/packages/cli/test/commands/project/list.test.ts b/packages/cli/test/commands/project/list.test.ts index 747747350..d0f603515 100644 --- a/packages/cli/test/commands/project/list.test.ts +++ b/packages/cli/test/commands/project/list.test.ts @@ -493,10 +493,10 @@ describe("handleExplicit", () => { test("a failing name fallback keeps the not-found hint", async () => { // A bad org: the project lookup and the fallback listing both 404. - globalThis.fetch = (() => + globalThis.fetch = () => Promise.resolve( new Response(JSON.stringify({ detail: "Not found" }), { status: 404 }), - )) as unknown as typeof globalThis.fetch; + ); const result = await handleExplicit("test-org", "frontnd", { limit: 30, @@ -671,10 +671,7 @@ describe("project list: comma-separated project slugs", () => { test("propagates lookup errors other than not found", async () => { const projectFetch = mockProjectFetch(sampleProjects); - globalThis.fetch = (async ( - input: RequestInfo | URL, - init?: RequestInit, - ) => { + globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit) => { if ( new Request(input, init).url.includes("/projects/test-org/backend/") ) { @@ -683,7 +680,7 @@ describe("project list: comma-separated project slugs", () => { }); } return await projectFetch(input, init); - }) as typeof globalThis.fetch; + }; const { context } = createCommandContext(); const error = await func diff --git a/packages/cli/test/commands/react-native/xcode.test.ts b/packages/cli/test/commands/react-native/xcode.test.ts index c88929943..58ec89242 100644 --- a/packages/cli/test/commands/react-native/xcode.test.ts +++ b/packages/cli/test/commands/react-native/xcode.test.ts @@ -129,8 +129,7 @@ describe("react-native xcode", () => { expect(wrapEnv?.__SENTRY_RN_WRAP_XCODE_CALL).toBe("1"); expect(sourcemaps.uploadSourcemaps).toHaveBeenCalledTimes(1); - const opts = vi.mocked(sourcemaps.uploadSourcemaps).mock - .calls[0][0] as sourcemaps.UploadOptions; + const opts = vi.mocked(sourcemaps.uploadSourcemaps).mock.calls[0][0]; expect(opts).toMatchObject({ org: "acme", project: "mobile", diff --git a/packages/cli/test/commands/repo/list.test.ts b/packages/cli/test/commands/repo/list.test.ts index 82e3e629e..23bc400f4 100644 --- a/packages/cli/test/commands/repo/list.test.ts +++ b/packages/cli/test/commands/repo/list.test.ts @@ -180,7 +180,7 @@ describe("listCommand.func — project-search (bare slug)", () => { test("shows count when results exceed limit", async () => { const manyRepos = Array.from({ length: 10 }, (_, i) => ({ - ...sampleRepos[0]!, + ...sampleRepos[0], id: String(i), name: `repo-${i}`, })); diff --git a/packages/cli/test/commands/status/show.test.ts b/packages/cli/test/commands/status/show.test.ts index 81ed99abc..e524e0415 100644 --- a/packages/cli/test/commands/status/show.test.ts +++ b/packages/cli/test/commands/status/show.test.ts @@ -19,13 +19,13 @@ type ShowFunc = (this: unknown, flags: ShowFlags) => Promise; let originalFetch: typeof globalThis.fetch; function mockFetch(payload: unknown, ok = true, status = 200): void { - globalThis.fetch = (async () => + globalThis.fetch = async () => ({ ok, status, json: async () => payload, text: async () => JSON.stringify(payload), - }) as unknown as Response) as typeof globalThis.fetch; + }) as unknown as Response; } /** Create a mock Stricli context with stdout capture. */ diff --git a/packages/cli/test/commands/team/list.test.ts b/packages/cli/test/commands/team/list.test.ts index b38640283..a9bfedaf5 100644 --- a/packages/cli/test/commands/team/list.test.ts +++ b/packages/cli/test/commands/team/list.test.ts @@ -175,7 +175,7 @@ describe("listCommand.func — project-search (bare slug)", () => { test("shows count when results exceed limit", async () => { const manyTeams = Array.from({ length: 10 }, (_, i) => ({ - ...sampleTeams[0]!, + ...sampleTeams[0], id: String(i), slug: `team-${i}`, name: `Team ${i}`, diff --git a/packages/cli/test/commands/trial/list.test.ts b/packages/cli/test/commands/trial/list.test.ts index 9aca12039..0c3f0a545 100644 --- a/packages/cli/test/commands/trial/list.test.ts +++ b/packages/cli/test/commands/trial/list.test.ts @@ -64,7 +64,7 @@ function createMockContext(cwd = "/tmp") { function daysFromNow(days: number): string { const d = new Date(); d.setDate(d.getDate() + days); - return d.toISOString().split("T")[0]!; + return d.toISOString().split("T")[0]; } /** diff --git a/packages/cli/test/commands/trial/start.test.ts b/packages/cli/test/commands/trial/start.test.ts index f6f0942ef..0ccc87788 100644 --- a/packages/cli/test/commands/trial/start.test.ts +++ b/packages/cli/test/commands/trial/start.test.ts @@ -261,7 +261,7 @@ describe("trial start command", () => { canTrial: true, isTrial: false, planDetails: { name: "Developer" }, - } as CustomerTrialInfo); + }); const { context } = createMockContext(); const func = await startCommand.loader(); diff --git a/packages/cli/test/e2e/explore.test.ts b/packages/cli/test/e2e/explore.test.ts index 8eea09bad..5895ac008 100644 --- a/packages/cli/test/e2e/explore.test.ts +++ b/packages/cli/test/e2e/explore.test.ts @@ -101,7 +101,7 @@ test("combines -b buckets with -t period and preserves metadata when projecting expect(result.exitCode, result.stderr + result.stdout).toBe(0); expect(requests).toHaveLength(1); - const params = requests[0]!.searchParams; + const params = requests[0].searchParams; expect(params.getAll("yAxis")).toEqual(["count()", "latest_event()"]); expect(Object.fromEntries(params)).toEqual({ dataset: "spans", diff --git a/packages/cli/test/e2e/local.test.ts b/packages/cli/test/e2e/local.test.ts index baa9dc7fb..d13c4af52 100644 --- a/packages/cli/test/e2e/local.test.ts +++ b/packages/cli/test/e2e/local.test.ts @@ -160,7 +160,7 @@ describe("Local daemon E2E", () => { } expect(text).toContain("event: sentry.local.directory"); directoryUrl = ( - JSON.parse(text.match(/data: (.+)/)![1]!) as { directoryUrl: string } + JSON.parse(text.match(/data: (.+)/)![1]) as { directoryUrl: string } ).directoryUrl; } finally { await bootstrapReader.cancel(); @@ -213,12 +213,12 @@ describe("Local daemon E2E", () => { const reader = stream.body!.getReader(); try { let text = ""; - while (!text.includes(expected!)) { + while (!text.includes(expected)) { const chunk = await reader.read(); if (chunk.done) throw new Error("Stream closed"); text += new TextDecoder().decode(chunk.value); } - expect(text).not.toContain(excluded!); + expect(text).not.toContain(excluded); } finally { await reader.cancel(); } @@ -662,7 +662,7 @@ describe("Local daemon E2E", () => { const event = await cli("event", "view", ...parts, eventId); expect(event.exitCode, event.stderr).toBe(0); expect(event.stdout).toContain("multi-word session event"); - const raw = await cli("envelope", "view", ...parts, envelopeId!); + const raw = await cli("envelope", "view", ...parts, envelopeId); expect(raw.exitCode, raw.stderr).toBe(0); const envelope = JSON.parse(raw.stdout) as { data: string }; expect(Buffer.from(envelope.data, "base64").toString()).toContain( diff --git a/packages/cli/test/fixtures/bench/generate.ts b/packages/cli/test/fixtures/bench/generate.ts index 28f009964..125cb7382 100644 --- a/packages/cli/test/fixtures/bench/generate.ts +++ b/packages/cli/test/fixtures/bench/generate.ts @@ -105,7 +105,7 @@ class XorShift32 { /** Pick one element from `arr`. */ pick(arr: readonly T[]): T { - return arr[this.int(arr.length)] as T; + return arr[this.int(arr.length)]; } /** Boolean true with probability `p`. */ diff --git a/packages/cli/test/fixtures/bench/helpers.ts b/packages/cli/test/fixtures/bench/helpers.ts index 7f26f3392..5e1fb6da2 100644 --- a/packages/cli/test/fixtures/bench/helpers.ts +++ b/packages/cli/test/fixtures/bench/helpers.ts @@ -112,8 +112,8 @@ export function summarize(samples: readonly number[]): BenchStats { } const sorted = [...samples].sort((a, b) => a - b); const n = sorted.length; - const min = sorted[0] as number; - const max = sorted[n - 1] as number; + const min = sorted[0]; + const max = sorted[n - 1]; const mean = sorted.reduce((acc, x) => acc + x, 0) / n; // Population stddev — we're measuring the full sample, not inferring a population. const variance = sorted.reduce((acc, x) => acc + (x - mean) ** 2, 0) / n; @@ -135,7 +135,7 @@ function percentile(sorted: readonly number[], p: number): number { sorted.length - 1, Math.max(0, Math.ceil(p * sorted.length) - 1), ); - return sorted[idx] as number; + return sorted[idx]; } /** @@ -293,8 +293,8 @@ export function compareReports( const [fixture, operation] = key.split("||"); if (!b) { rows.push({ - fixture: fixture as string, - operation: operation as string, + fixture: fixture, + operation: operation, current: c?.stats, verdict: "missing-baseline", }); @@ -302,8 +302,8 @@ export function compareReports( } if (!c) { rows.push({ - fixture: fixture as string, - operation: operation as string, + fixture: fixture, + operation: operation, baseline: b.stats, verdict: "missing-current", }); @@ -315,8 +315,8 @@ export function compareReports( if (deltaPct > thresholdPct) verdict = "regressed"; else if (deltaPct < -thresholdPct) verdict = "improved"; rows.push({ - fixture: fixture as string, - operation: operation as string, + fixture: fixture, + operation: operation, baseline: b.stats, current: c.stats, deltaMs, diff --git a/packages/cli/test/helpers.ts b/packages/cli/test/helpers.ts index 621a0c1ac..43477b62f 100644 --- a/packages/cli/test/helpers.ts +++ b/packages/cli/test/helpers.ts @@ -87,7 +87,7 @@ type FetchMockFn = * @returns Properly typed fetch function */ export function mockFetch(fn: FetchMockFn): typeof fetch { - return fn as unknown as typeof fetch; + return fn; } /** @@ -291,7 +291,7 @@ export function installFetchMock( const fallbackStatus = fallback?.status ?? 404; const fallbackBody = fallback?.body ?? { detail: "Not found" }; - globalThis.fetch = (async ( + globalThis.fetch = async ( input: RequestInfo | URL, init?: RequestInit, // test mock router requires branching for method/URL/body matching @@ -342,7 +342,7 @@ export function installFetchMock( status: fallbackStatus, headers: { "Content-Type": "application/json" }, }); - }) as typeof fetch; + }; return { calls, diff --git a/packages/cli/test/lib/alias.property.test.ts b/packages/cli/test/lib/alias.property.test.ts index 71b008218..18900a8bf 100644 --- a/packages/cli/test/lib/alias.property.test.ts +++ b/packages/cli/test/lib/alias.property.test.ts @@ -441,7 +441,7 @@ describe("property: cross-function invariants", () => { // Aliases should be shorter than full project slugs for (const [key, alias] of aliasMap) { - const project = key.split("/")[1]!; + const project = key.split("/")[1]; expect(alias.length).toBeLessThanOrEqual(project.length); } }), @@ -469,7 +469,7 @@ describe("property: cross-function invariants", () => { // Aliases should match direct prefixes for simple unique slugs for (const [key, alias] of aliasMap) { - const project = key.split("/")[1]!; + const project = key.split("/")[1]; expect(directPrefixes.get(project)).toBe(alias); } }, diff --git a/packages/cli/test/lib/api-client.coverage.test.ts b/packages/cli/test/lib/api-client.coverage.test.ts index d08250335..321a0f902 100644 --- a/packages/cli/test/lib/api-client.coverage.test.ts +++ b/packages/cli/test/lib/api-client.coverage.test.ts @@ -118,7 +118,7 @@ describe("issues.ts", () => { const issue = mockIssue(); const requested: string[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const { pathname } = new URL(new Request(input!, init).url); + const { pathname } = new URL(new Request(input, init).url); requested.push(pathname); if (pathname.includes("/organizations/has-it/")) { return new Response(JSON.stringify(issue), { @@ -156,7 +156,7 @@ describe("issues.ts", () => { test("throws an unexpected error when no org has the issue", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const { pathname } = new URL(new Request(input!, init).url); + const { pathname } = new URL(new Request(input, init).url); const status = pathname.includes("/organizations/broken/") ? 500 : 404; return new Response(JSON.stringify({ detail: "boom" }), { status, @@ -174,7 +174,7 @@ describe("issues.ts", () => { test("fetches issue scoped to organization", async () => { const issue = mockIssue(); globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/organizations/test-org/issues/12345/"); return new Response(JSON.stringify(issue), { status: 200, @@ -189,7 +189,7 @@ describe("issues.ts", () => { test("passes only the collapse values the details endpoint reads", async () => { const issue = mockIssue(); globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.pathname).toContain("/organizations/test-org/issues/12345/"); expect(url.searchParams.getAll("collapse")).toEqual(["stats"]); @@ -207,7 +207,7 @@ describe("issues.ts", () => { test("omits collapse when no value applies to the details endpoint", async () => { const issue = mockIssue(); globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); expect(url.searchParams.has("collapse")).toBe(false); return Response.json(issue); }); @@ -222,7 +222,7 @@ describe("issues.ts", () => { test("resolves short ID to issue (uppercases input)", async () => { const issue = mockIssue({ shortId: "TEST-1" }); globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/shortids/TEST-1/"); return new Response(JSON.stringify({ group: issue }), { status: 200, @@ -254,7 +254,7 @@ describe("issues.ts", () => { test("passes collapse query params when provided", async () => { const issue = mockIssue({ shortId: "TEST-1" }); globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.pathname).toContain("/shortids/TEST-1/"); expect(url.searchParams.getAll("collapse")).toEqual([ @@ -321,7 +321,7 @@ describe("issues.ts", () => { let capturedBody: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; capturedBody = await req.json(); expect(req.method).toBe("PUT"); @@ -376,7 +376,7 @@ describe("issues.ts", () => { globalThis.fetch = mockFetch(async (input, init) => { callCount += 1; - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); if (callCount === 1) { @@ -448,7 +448,7 @@ describe("issues.ts", () => { let capturedUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; return new Response(JSON.stringify([mockIssue({ id: "1" })]), { status: 200, @@ -477,7 +477,7 @@ describe("teams.ts", () => { const teams = [mockTeam({ id: "1" }), mockTeam({ id: "2" })]; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/organizations/test-org/teams/"); return new Response(JSON.stringify(teams), { status: 200, @@ -495,7 +495,7 @@ describe("teams.ts", () => { const teams = [mockTeam()]; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/projects/test-org/test-project/teams/"); return new Response(JSON.stringify(teams), { status: 200, @@ -505,7 +505,7 @@ describe("teams.ts", () => { const result = await listProjectTeams("test-org", "test-project"); expect(result).toHaveLength(1); - expect(result[0]!.slug).toBe("test-team"); + expect(result[0].slug).toBe("test-team"); }); }); @@ -515,7 +515,7 @@ describe("teams.ts", () => { const requestUrls: string[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); requestUrls.push(req.url); if ( @@ -546,7 +546,7 @@ describe("teams.ts", () => { const team = mockTeam({ slug: "new-team" }); globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if ( req.method === "POST" && @@ -572,7 +572,7 @@ describe("teams.ts", () => { describe("addMemberToTeam", () => { test("adds member to team", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/members/me/teams/test-team/"); expect(req.method).toBe("POST"); return new Response(JSON.stringify({}), { @@ -658,7 +658,7 @@ describe("projects.ts", () => { test("passes cursor and perPage options", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("cursor")).toBe("my-cursor"); expect(url.searchParams.get("per_page")).toBe("50"); @@ -676,7 +676,7 @@ describe("projects.ts", () => { test("caps perPage at API_MAX_PER_PAGE", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("per_page")).toBe(String(API_MAX_PER_PAGE)); return new Response(JSON.stringify([]), { @@ -695,7 +695,7 @@ describe("projects.ts", () => { let callCount = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); const perPage = Number(url.searchParams.get("per_page")); perPageValues.push(perPage); @@ -729,7 +729,7 @@ describe("projects.ts", () => { let callCount = 0; globalThis.fetch = mockFetch(async (input, init) => { callCount += 1; - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("per_page")).toBe("25"); return new Response(JSON.stringify([mockProject()]), { @@ -749,7 +749,7 @@ describe("projects.ts", () => { const project = mockProject({ slug: "new-project" }); globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/teams/test-org/test-team/projects/"); expect(req.method).toBe("POST"); return new Response(JSON.stringify(project), { @@ -784,7 +784,7 @@ describe("projects.ts", () => { test("POSTs to /organizations/{org}/projects/ and returns project with DSN and team_slug", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.url.includes("/projects/") && req.method === "POST") { return new Response(JSON.stringify(autoTeamProject), { status: 201, @@ -823,7 +823,7 @@ describe("projects.ts", () => { test("returns dsn:null when DSN fetch fails", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.method === "POST") { return new Response(JSON.stringify(autoTeamProject), { status: 201, @@ -855,7 +855,7 @@ describe("projects.ts", () => { ]; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/projects/test-org/test-project/keys/"); expect(new URL(req.url).searchParams.get("status")).toBe("active"); return new Response(JSON.stringify(keys), { @@ -868,7 +868,7 @@ describe("projects.ts", () => { status: "active", }); expect(result).toHaveLength(1); - expect(result[0]!.dsn.public).toBe("https://abc@sentry.io/1"); + expect(result[0].dsn.public).toBe("https://abc@sentry.io/1"); }); }); @@ -1007,7 +1007,7 @@ describe("users.ts", () => { }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/api/0/auth/"); return new Response(JSON.stringify(user), { status: 200, @@ -1046,7 +1046,7 @@ describe("events.ts", () => { const event = { eventID: "evt-abc", title: "Error" }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/organizations/test-org/issues/"); expect(req.url).toContain("/events/latest/"); return new Response(JSON.stringify(event), { @@ -1065,7 +1065,7 @@ describe("events.ts", () => { const event = { eventID: "evt-abc" }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain( "/projects/test-org/test-project/events/evt-abc/", ); @@ -1084,7 +1084,7 @@ describe("events.ts", () => { test("returns attachment metadata from every API page", async () => { let requestCount = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.pathname).toContain( "/projects/test-org/test-project/events/evt-abc/attachments/", @@ -1195,7 +1195,7 @@ describe("traces.ts", () => { ]; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain( "/organizations/test-org/trace/abc123def456/", ); @@ -1213,7 +1213,7 @@ describe("traces.ts", () => { timestamp: 1_700_000_000, }); expect(result).toHaveLength(1); - expect(result[0]!.span_id).toBe("span-1"); + expect(result[0].span_id).toBe("span-1"); }); }); }); @@ -1236,7 +1236,7 @@ describe("repositories.ts", () => { ]; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/organizations/test-org/repos/"); return new Response(JSON.stringify(repos), { status: 200, @@ -1246,7 +1246,7 @@ describe("repositories.ts", () => { const result = await listRepositories("test-org"); expect(result).toHaveLength(1); - expect(result[0]!.name).toBe("getsentry/sentry"); + expect(result[0].name).toBe("getsentry/sentry"); }); }); @@ -1319,7 +1319,7 @@ describe("logs.ts", () => { }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/organizations/test-org/events/"); const url = new URL(req.url); expect(url.searchParams.get("dataset")).toBe("logs"); @@ -1333,14 +1333,14 @@ describe("logs.ts", () => { const result = await listLogs("test-org", "my-project"); expect(result).toHaveLength(1); - expect(result[0]!["sentry.item_id"]).toBe("log-1"); + expect(result[0]["sentry.item_id"]).toBe("log-1"); }); test("uses numeric project ID via project param", async () => { const logsResponse = { data: [], meta: { fields: {} } }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); // Numeric ID should be passed as project param, not in query expect(url.searchParams.get("project")).toBe("42"); @@ -1362,7 +1362,7 @@ describe("logs.ts", () => { const logsResponse = { data: [], meta: {} }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); const query = url.searchParams.get("query") ?? ""; expect(query).toContain("timestamp_precise:>1700000000"); @@ -1381,7 +1381,7 @@ describe("logs.ts", () => { const logsResponse = { data: [], meta: {} }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); const query = url.searchParams.get("query") ?? ""; expect(query).toContain("severity:error"); @@ -1408,7 +1408,7 @@ describe("infrastructure.ts", () => { describe("apiRequest", () => { test("makes GET request to default base URL", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/api/0/organizations/"); expect(req.method).toBe("GET"); return new Response(JSON.stringify([{ slug: "org1" }]), { @@ -1785,7 +1785,7 @@ describe("teams.ts (paginated)", () => { test("passes cursor and perPage options", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("cursor")).toBe("my-cursor"); return new Response(JSON.stringify([]), { @@ -1837,7 +1837,7 @@ describe("repositories.ts (paginated)", () => { test("passes cursor and perPage options", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("cursor")).toBe("repo-cursor"); return new Response(JSON.stringify([]), { @@ -1876,7 +1876,7 @@ describe("traces.ts (transactions)", () => { }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.pathname).toContain("/organizations/test-org/events/"); expect(url.searchParams.get("dataset")).toBe("spans"); @@ -1895,7 +1895,7 @@ describe("traces.ts (transactions)", () => { limit: 1, }); expect(result.data).toHaveLength(1); - expect(result.data[0]!.transaction).toBe("GET /api/users"); + expect(result.data[0].transaction).toBe("GET /api/users"); expect(result.nextCursor).toContain("txn-next"); }); @@ -1906,7 +1906,7 @@ describe("traces.ts (transactions)", () => { }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("project")).toBe("42"); const query = url.searchParams.get("query"); @@ -1926,7 +1926,7 @@ describe("traces.ts (transactions)", () => { const txnResponse = { data: [], meta: {} }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("sort")).toBe("-span.duration"); expect(url.searchParams.get("statsPeriod")).toBe("24h"); @@ -1946,7 +1946,7 @@ describe("traces.ts (transactions)", () => { const txnResponse = { data: [], meta: {} }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("sort")).toBe("-timestamp"); return new Response(JSON.stringify(txnResponse), { @@ -1982,7 +1982,7 @@ describe("logs.ts (detailed)", () => { }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); const query = url.searchParams.get("query") ?? ""; expect(query).toContain("sentry.item_id:[log-1]"); @@ -1995,7 +1995,7 @@ describe("logs.ts (detailed)", () => { const result = await getLogs("test-org", "test-project", ["log-1"]); expect(result).toHaveLength(1); - expect(result[0]!["sentry.item_id"]).toBe("log-1"); + expect(result[0]["sentry.item_id"]).toBe("log-1"); }); test("splits into batches when over API_MAX_PER_PAGE", async () => { @@ -2004,7 +2004,7 @@ describe("logs.ts (detailed)", () => { let callCount = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); // The SDK uses /events/ endpoint for logs @@ -2056,7 +2056,7 @@ describe("logs.ts (detailed)", () => { }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.pathname).toContain("/organizations/test-org/trace-logs/"); expect(url.searchParams.getAll("traceId")).toEqual(["abc123def456"]); @@ -2070,14 +2070,14 @@ describe("logs.ts (detailed)", () => { const result = await listTraceLogs("test-org", "abc123def456"); expect(result).toHaveLength(1); - expect(result[0]!.id).toBe("tlog-1"); + expect(result[0].id).toBe("tlog-1"); }); test("passes custom statsPeriod and limit", async () => { const traceLogsResponse = { data: [], meta: {} }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("statsPeriod")).toBe("7d"); expect(url.searchParams.get("per_page")).toBe("50"); @@ -2097,7 +2097,7 @@ describe("logs.ts (detailed)", () => { const traceLogsResponse = { data: [], meta: {} }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("query")).toBe("severity:error"); return new Response(JSON.stringify(traceLogsResponse), { @@ -2129,7 +2129,7 @@ describe("events.ts (findEventAcrossOrgs)", () => { }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); // listOrganizations → listOrganizationsPage (control silo) if ( @@ -2169,7 +2169,7 @@ describe("infrastructure.ts (rawApiRequest)", () => { describe("rawApiRequest", () => { test("makes GET request and returns status, headers, body", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("GET"); expect(req.url).toContain("/api/0/organizations/"); return new Response(JSON.stringify({ data: "test" }), { @@ -2219,7 +2219,7 @@ describe("infrastructure.ts (rawApiRequest)", () => { let capturedContentType = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedContentType = req.headers.get("Content-Type") ?? ""; capturedBody = await req.json(); return new Response(JSON.stringify({}), { @@ -2240,7 +2240,7 @@ describe("infrastructure.ts (rawApiRequest)", () => { let capturedBody = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedBody = await req.text(); return new Response(JSON.stringify({}), { status: 200, @@ -2259,7 +2259,7 @@ describe("infrastructure.ts (rawApiRequest)", () => { let capturedAccept = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedAccept = req.headers.get("Accept") ?? ""; return new Response(JSON.stringify({}), { status: 200, diff --git a/packages/cli/test/lib/api/alerts.test.ts b/packages/cli/test/lib/api/alerts.test.ts index 550ee5a57..6a28d368c 100644 --- a/packages/cli/test/lib/api/alerts.test.ts +++ b/packages/cli/test/lib/api/alerts.test.ts @@ -39,7 +39,7 @@ afterEach(() => { describe("deleteIssueAlertRule", () => { test("treats empty-body 204 as success", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("DELETE"); expect(req.url).toBe( `${DEFAULT_SENTRY_URL}/api/0/organizations/test-org/workflows/42/`, @@ -76,7 +76,7 @@ function workflowRule(overrides: Record) { describe("listIssueAlertsPaginated", () => { test("reads from org-scoped /workflows/ and drops unattached workflows", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); expect(url.pathname).toBe("/api/0/organizations/test-org/workflows/"); expect(url.searchParams.getAll("project")).toEqual(["test-project"]); expect(url.searchParams.has("projectSlug")).toBe(false); @@ -96,7 +96,7 @@ describe("listIssueAlertsPaginated", () => { describe("getIssueAlertRule", () => { test("reads from /workflows/ filtered by project and id", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); expect(url.pathname).toBe("/api/0/organizations/test-org/workflows/"); expect(url.searchParams.getAll("project")).toEqual(["test-project"]); expect(url.searchParams.has("projectSlug")).toBe(false); @@ -150,7 +150,7 @@ function metricDetector(overrides: Record) { describe("listMetricAlertsPaginated", () => { test("reads from org-scoped /detectors/ filtered to metric_issue and flattens the payload", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); expect(url.pathname).toBe("/api/0/organizations/test-org/detectors/"); expect(url.searchParams.get("query")).toBe("type:metric_issue"); return Response.json([ @@ -181,7 +181,7 @@ describe("listMetricAlertsPaginated", () => { describe("getMetricAlertRule", () => { test("reads from /detectors/{id}/ and maps disabled detectors to status 1", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); expect(url.pathname).toBe("/api/0/organizations/test-org/detectors/9/"); return Response.json( metricDetector({ id: "9", name: "Disabled rule", enabled: false }), @@ -337,7 +337,7 @@ describe("getMetricAlertRule", () => { describe("createIssueAlertRule", () => { test("POSTs the body to the org-scoped /workflows/ endpoint", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("POST"); expect(new URL(req.url).pathname).toBe( "/api/0/organizations/test-org/workflows/", @@ -357,7 +357,7 @@ describe("createIssueAlertRule", () => { describe("updateIssueAlertRule", () => { test("PUTs the body to the /workflows/{id}/ endpoint", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("PUT"); expect(new URL(req.url).pathname).toBe( "/api/0/organizations/test-org/workflows/42/", @@ -376,7 +376,7 @@ describe("updateIssueAlertRule", () => { describe("getIssueAlertWorkflowDocument", () => { test("reads the single workflow detail endpoint", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); expect(url.pathname).toBe("/api/0/organizations/test-org/workflows/42/"); return Response.json(workflowRule({ id: "42" })); }); @@ -389,7 +389,7 @@ describe("getIssueAlertWorkflowDocument", () => { describe("resolveErrorDetectorId", () => { test("returns the id of the project's error detector", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); expect(url.pathname).toBe("/api/0/organizations/test-org/detectors/"); expect(url.searchParams.get("project")).toBe("test-project"); expect(url.searchParams.get("query")).toBe("type:error"); @@ -413,7 +413,7 @@ describe("resolveErrorDetectorId", () => { describe("deleteMetricAlertRule", () => { test("deletes via the org-scoped /detectors/{id}/ endpoint", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("DELETE"); expect(new URL(req.url).pathname).toBe( "/api/0/organizations/test-org/detectors/9/", @@ -431,7 +431,7 @@ describe("deleteMetricAlertRule", () => { describe("createMetricAlertRule", () => { test("POSTs a nested detector body to the project-scoped /detectors/ endpoint", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("POST"); expect(new URL(req.url).pathname).toBe( "/api/0/organizations/test-org/projects/backend/detectors/", @@ -483,7 +483,7 @@ describe("createMetricAlertRule", () => { test("maps error-like datasets to queryType 0 and error eventTypes", async () => { let sentBody: Record = {}; globalThis.fetch = mockFetch(async (input, init) => { - sentBody = (await new Request(input!, init).json()) as Record< + sentBody = (await new Request(input, init).json()) as Record< string, unknown >; @@ -510,7 +510,7 @@ describe("createMetricAlertRule", () => { test("maps logs to the EAP dataset with trace_item_log and connects workflows", async () => { let sentBody: Record = {}; globalThis.fetch = mockFetch(async (input, init) => { - sentBody = (await new Request(input!, init).json()) as Record< + sentBody = (await new Request(input, init).json()) as Record< string, unknown >; @@ -551,7 +551,7 @@ describe("createMetricAlertRule", () => { test("maps sessions to the crash-rate metrics dataset", async () => { let sentBody: Record = {}; globalThis.fetch = mockFetch(async (input, init) => { - sentBody = (await new Request(input!, init).json()) as Record< + sentBody = (await new Request(input, init).json()) as Record< string, unknown >; @@ -578,7 +578,7 @@ describe("createMetricAlertRule", () => { test("translates warning and below-threshold triggers", async () => { let sentBody: Record = {}; globalThis.fetch = mockFetch(async (input, init) => { - sentBody = (await new Request(input!, init).json()) as Record< + sentBody = (await new Request(input, init).json()) as Record< string, unknown >; @@ -610,7 +610,7 @@ describe("createMetricAlertRule", () => { test("drops empty trigger actions from detector conditions", async () => { let sentBody: Record = {}; globalThis.fetch = mockFetch(async (input, init) => { - sentBody = (await new Request(input!, init).json()) as Record< + sentBody = (await new Request(input, init).json()) as Record< string, unknown >; @@ -642,7 +642,7 @@ describe("createMetricAlertRule", () => { test("passes native detector conditions through unchanged", async () => { let sentBody: Record = {}; globalThis.fetch = mockFetch(async (input, init) => { - sentBody = (await new Request(input!, init).json()) as Record< + sentBody = (await new Request(input, init).json()) as Record< string, unknown >; @@ -685,7 +685,7 @@ describe("createMetricAlertRule", () => { describe("getMetricAlertRuleDocument", () => { test("returns the flat rule baseline from the detector GET", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); expect(url.pathname).toBe("/api/0/organizations/test-org/detectors/9/"); return Response.json(metricDetector({ id: "9", name: "Baseline" })); }); @@ -718,7 +718,7 @@ describe("metric alert edit round-trip", () => { }; let putSource: Record | undefined; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.method === "PUT") { const body = (await req.json()) as Record; putSource = (body.dataSources as Record[])[0]; @@ -759,7 +759,7 @@ describe("metric alert edit round-trip without event types", () => { }; let putSource: Record | undefined; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.method === "PUT") { const body = (await req.json()) as Record; putSource = (body.dataSources as Record[])[0]; @@ -785,7 +785,7 @@ describe("metric alert edit round-trip of detector config", () => { const storedConfig = { detectionType: "percent", comparisonDelta: 3600 }; let putConfig: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.method === "PUT") { const body = (await req.json()) as Record; putConfig = body.config; @@ -807,7 +807,7 @@ describe("metric alert edit round-trip of detector config", () => { async (_label, storedConfig) => { let putConfig: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.method === "PUT") { const body = (await req.json()) as Record; putConfig = body.config; @@ -829,7 +829,7 @@ describe("metric alert edit round-trip of detector config", () => { const storedConfig = { detectionType: "percent", comparisonDelta: 3600 }; let putConfig: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.method === "PUT") { const body = (await req.json()) as Record; putConfig = body.config; @@ -852,7 +852,7 @@ describe("metric alert edit round-trip of detector config", () => { test("defaults to static detection without a stored config", async () => { let putConfig: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.method === "PUT") { const body = (await req.json()) as Record; putConfig = body.config; @@ -869,7 +869,7 @@ describe("metric alert edit round-trip of detector config", () => { describe("putMetricAlertRule", () => { test("PUTs a nested detector body to the /detectors/{id}/ endpoint", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("PUT"); expect(new URL(req.url).pathname).toBe( "/api/0/organizations/test-org/detectors/9/", diff --git a/packages/cli/test/lib/api/code-mappings.test.ts b/packages/cli/test/lib/api/code-mappings.test.ts index dcd099155..8df370a31 100644 --- a/packages/cli/test/lib/api/code-mappings.test.ts +++ b/packages/cli/test/lib/api/code-mappings.test.ts @@ -26,7 +26,7 @@ describe("uploadCodeMappings", () => { test("POSTs a snake_case body to the bulk endpoint", async () => { let body: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("POST"); expect(req.url).toBe( `${DEFAULT_SENTRY_URL}/api/0/organizations/test-org/code-mappings/bulk/`, diff --git a/packages/cli/test/lib/api/conversations.test.ts b/packages/cli/test/lib/api/conversations.test.ts index 5512ef7c0..b7c633409 100644 --- a/packages/cli/test/lib/api/conversations.test.ts +++ b/packages/cli/test/lib/api/conversations.test.ts @@ -37,7 +37,7 @@ function mockOk( let capturedMethod = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; capturedMethod = req.method; return new Response(JSON.stringify(body), { @@ -63,10 +63,10 @@ function mockSequential( let callIndex = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); - const resp = responses[callIndex]!; + const resp = responses[callIndex]; callIndex += 1; return new Response(JSON.stringify(resp.body), { diff --git a/packages/cli/test/lib/api/dashboards.test.ts b/packages/cli/test/lib/api/dashboards.test.ts index d755a0610..9333232c9 100644 --- a/packages/cli/test/lib/api/dashboards.test.ts +++ b/packages/cli/test/lib/api/dashboards.test.ts @@ -202,7 +202,7 @@ function makeWidget(layoutW?: number, interval?: string): DashboardWidget { layout: layoutW !== undefined ? { x: 0, y: 0, w: layoutW, h: 2 } : undefined, interval, - } as DashboardWidget; + }; } describe("computeOptimalInterval", () => { diff --git a/packages/cli/test/lib/api/debug-files.test.ts b/packages/cli/test/lib/api/debug-files.test.ts index fc3113855..3bfd1de3b 100644 --- a/packages/cli/test/lib/api/debug-files.test.ts +++ b/packages/cli/test/lib/api/debug-files.test.ts @@ -86,15 +86,13 @@ function setServerOptions(overrides: Record): void { vi.mocked(getChunkUploadOptions).mockResolvedValue({ ...BASE_SERVER_OPTIONS, ...overrides, - } as Awaited>); + }); } beforeEach(() => { assembleMock.mockReset(); uploadChunkPayloadsMock.mockClear(); - vi.mocked(getChunkUploadOptions).mockResolvedValue( - BASE_SERVER_OPTIONS as Awaited>, - ); + vi.mocked(getChunkUploadOptions).mockResolvedValue(BASE_SERVER_OPTIONS); }); afterEach(() => { @@ -140,7 +138,7 @@ describe("uploadDebugFiles", () => { const keys = Object.keys(body); expect(keys).toHaveLength(1); expect(keys[0]).toMatch(/^[0-9a-f]{40}$/); - const entry = body[keys[0] as string]; + const entry = body[keys[0]]; expect(entry?.name).toBe("libfoo.so"); expect(entry?.debug_id).toBe("abc123-def"); expect(Array.isArray(entry?.chunks)).toBe(true); @@ -183,7 +181,7 @@ describe("uploadDebugFiles", () => { assembleMock.mockImplementationOnce( async (_org: string, _project: string, assembleBody: object) => { const body = assembleBody as Record; - const key = Object.keys(body)[0] as string; + const key = Object.keys(body)[0]; return { [key]: { state: "not_found", missingChunks: body[key]?.chunks }, }; @@ -191,7 +189,7 @@ describe("uploadDebugFiles", () => { ); assembleMock.mockImplementationOnce( async (_org: string, _project: string, assembleBody: object) => { - const key = Object.keys(assembleBody as object)[0] as string; + const key = Object.keys(assembleBody)[0]; return { [key]: { state: "created" } }; }, ); @@ -216,13 +214,13 @@ describe("uploadDebugFiles", () => { assembleMock.mockImplementationOnce( async (_org: string, _project: string, assembleBody: object) => { - const key = Object.keys(assembleBody as object)[0] as string; + const key = Object.keys(assembleBody)[0]; return { [key]: { state: "assembling" } }; }, ); assembleMock.mockImplementationOnce( async (_org: string, _project: string, assembleBody: object) => { - const key = Object.keys(assembleBody as object)[0] as string; + const key = Object.keys(assembleBody)[0]; return { [key]: { state: "ok" } }; }, ); @@ -244,7 +242,7 @@ describe("uploadDebugFiles", () => { const dif = makeDif("broken.so", "debug bytes", "id-3"); assembleMock.mockImplementationOnce( async (_org: string, _project: string, assembleBody: object) => { - const key = Object.keys(assembleBody as object)[0] as string; + const key = Object.keys(assembleBody)[0]; return { [key]: { state: "error", detail: "corrupt object" } }; }, ); @@ -265,7 +263,7 @@ describe("uploadDebugFiles", () => { // Always "assembling" → never terminal. maxWaitMs=0 trips the deadline. assembleMock.mockImplementation( async (_org: string, _project: string, assembleBody: object) => { - const key = Object.keys(assembleBody as object)[0] as string; + const key = Object.keys(assembleBody)[0]; return { [key]: { state: "assembling" } }; }, ); @@ -421,13 +419,13 @@ describe("uploadDebugFiles", () => { // would poll forever without sending anything. assembleMock.mockImplementationOnce( async (_org: string, _project: string, assembleBody: object) => { - const key = Object.keys(assembleBody as object)[0] as string; + const key = Object.keys(assembleBody)[0]; return { [key]: { state: "not_found" } }; }, ); assembleMock.mockImplementationOnce( async (_org: string, _project: string, assembleBody: object) => { - const key = Object.keys(assembleBody as object)[0] as string; + const key = Object.keys(assembleBody)[0]; return { [key]: { state: "ok" } }; }, ); @@ -505,7 +503,7 @@ describe("uploadDebugFiles", () => { // well before the requested 60s. assembleMock.mockImplementation( async (_org: string, _project: string, assembleBody: object) => { - const key = Object.keys(assembleBody as object)[0] as string; + const key = Object.keys(assembleBody)[0]; return { [key]: { state: "assembling" } }; }, ); @@ -528,7 +526,7 @@ describe("uploadDebugFiles", () => { const dif = makeDif("ok.so", "debug bytes", "id-ok"); assembleMock.mockImplementationOnce( async (_org: string, _project: string, assembleBody: object) => { - const key = Object.keys(assembleBody as object)[0] as string; + const key = Object.keys(assembleBody)[0]; return { [key]: { state: "ok" } }; }, ); diff --git a/packages/cli/test/lib/api/dropped-events.test.ts b/packages/cli/test/lib/api/dropped-events.test.ts index c18ebd2d2..992be2418 100644 --- a/packages/cli/test/lib/api/dropped-events.test.ts +++ b/packages/cli/test/lib/api/dropped-events.test.ts @@ -11,7 +11,7 @@ function mockOk(body: unknown): { let capturedUrl = ""; let capturedMethod = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; capturedMethod = req.method; return new Response(JSON.stringify(body), { diff --git a/packages/cli/test/lib/api/events-overshoot.test.ts b/packages/cli/test/lib/api/events-overshoot.test.ts index a62afb4c6..7632ec187 100644 --- a/packages/cli/test/lib/api/events-overshoot.test.ts +++ b/packages/cli/test/lib/api/events-overshoot.test.ts @@ -33,7 +33,7 @@ describe("listIssueEvents pagination", () => { test("sends per_page capped at the requested limit", async () => { let capturedUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - capturedUrl = new Request(input!, init).url; + capturedUrl = new Request(input, init).url; return new Response(JSON.stringify(makeEvents(2)), { status: 200, headers: { "Content-Type": "application/json" }, @@ -48,7 +48,7 @@ describe("listIssueEvents pagination", () => { test("caps per_page at API_MAX_PER_PAGE for very large limits", async () => { let capturedUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - capturedUrl = new Request(input!, init).url; + capturedUrl = new Request(input, init).url; return new Response(JSON.stringify(makeEvents(10)), { status: 200, headers: { "Content-Type": "application/json" }, diff --git a/packages/cli/test/lib/api/explore.test.ts b/packages/cli/test/lib/api/explore.test.ts index 837a014cb..6e25aceae 100644 --- a/packages/cli/test/lib/api/explore.test.ts +++ b/packages/cli/test/lib/api/explore.test.ts @@ -32,7 +32,7 @@ describe("queryEvents", () => { function mockOk(body: unknown, headers: Record = {}) { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; capturedMethod = req.method; return new Response(JSON.stringify(body), { @@ -249,10 +249,10 @@ describe("queryEvents", () => { let callIndex = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); - const resp = responses[callIndex]!; + const resp = responses[callIndex]; callIndex += 1; return new Response(JSON.stringify(resp.body), { @@ -380,7 +380,7 @@ describe("queryEventsTimeSeries", () => { function mockResponse(body: unknown, status = 200) { globalThis.fetch = mockFetch(async (input, init) => { - requests.push(new Request(input!, init)); + requests.push(new Request(input, init)); return new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" }, @@ -445,7 +445,7 @@ describe("queryEventsTimeSeries", () => { expect(result).toEqual(response); expect(requests).toHaveLength(1); - const request = requests[0]!; + const request = requests[0]; const url = new URL(request.url); expect(request.method).toBe("GET"); expect(url.origin).toBe("https://de.sentry.io"); @@ -509,7 +509,7 @@ describe("queryEventsTimeSeries", () => { }); expect(result).toEqual(response); - const params = new URL(requests[0]!.url).searchParams; + const params = new URL(requests[0].url).searchParams; expect(params.getAll("yAxis")).toEqual([ "max(timestamp)", "latest_event()", @@ -532,7 +532,7 @@ describe("queryEventsTimeSeries", () => { }); expect(result).toEqual({ timeSeries: [] }); - const params = new URL(requests[0]!.url).searchParams; + const params = new URL(requests[0].url).searchParams; expect(params.get("dataset")).toBe("tracemetrics"); expect(params.get("start")).toBe("2024-10-20T12:00:00Z"); expect(params.get("end")).toBe("2024-10-20T13:00:00Z"); diff --git a/packages/cli/test/lib/api/infrastructure.test.ts b/packages/cli/test/lib/api/infrastructure.test.ts index 1a8e535dc..7554fd67d 100644 --- a/packages/cli/test/lib/api/infrastructure.test.ts +++ b/packages/cli/test/lib/api/infrastructure.test.ts @@ -870,7 +870,7 @@ describe("rawApiRequest binary handling", () => { host: "https://sentry.io", }); const fetchSpy = vi.fn(); - globalThis.fetch = fetchSpy as unknown as typeof fetch; + globalThis.fetch = fetchSpy; await expect( rawApiRequest("organizations/", { diff --git a/packages/cli/test/lib/api/integrations.test.ts b/packages/cli/test/lib/api/integrations.test.ts index e8339eb32..b3a34444b 100644 --- a/packages/cli/test/lib/api/integrations.test.ts +++ b/packages/cli/test/lib/api/integrations.test.ts @@ -77,7 +77,7 @@ describe("integration API", () => { expect(page.data).toEqual([integration]); expect(page.nextCursor).toBe("0:25:0"); expect(calls).toHaveLength(1); - const { url, method } = calls[0]!; + const { url, method } = calls[0]; expect(method).toBe("GET"); expect(url.pathname).toBe("/api/0/organizations/my-org/integrations/"); expect(url.searchParams.get("includeConfig")).toBe("0"); diff --git a/packages/cli/test/lib/api/issue-app-links.test.ts b/packages/cli/test/lib/api/issue-app-links.test.ts index 7c2186135..0d4739c8b 100644 --- a/packages/cli/test/lib/api/issue-app-links.test.ts +++ b/packages/cli/test/lib/api/issue-app-links.test.ts @@ -156,7 +156,7 @@ describe("app issue-link action", () => { }); expect(writes()).toHaveLength(1); expect( - new globalThis.URL(writes()[0]!.url).searchParams.get( + new globalThis.URL(writes()[0].url).searchParams.get( "expectedExternalIssueUrl", ), ).toBe(URL); @@ -210,10 +210,10 @@ describe("app issue-link action", () => { link: links[0], }); expect( - new globalThis.URL(writes()[0]!.url).searchParams.get( + new globalThis.URL(writes()[0].url).searchParams.get( "expectedExternalIssueUrl", ), - ).toBe(links[0]!.webUrl); + ).toBe(links[0].webUrl); expect(await writes()[0]?.json()).toMatchObject({ uri: FORM.uri, issueId: "linear-uuid", @@ -284,7 +284,7 @@ describe("app issue-link action", () => { }); expect(await writes()[0]?.json()).toMatchObject({ task_id: "123" }); expect( - new globalThis.URL(writes()[0]!.url).searchParams.get( + new globalThis.URL(writes()[0].url).searchParams.get( "expectedExternalIssueUrl", ), ).toBe(url); @@ -349,9 +349,9 @@ describe("app issue-link action", () => { fields, }); await linkAppIssue(prepared); - expect(await writes()[0]!.json()).toMatchObject({ url }); + expect(await writes()[0].json()).toMatchObject({ url }); expect( - new globalThis.URL(writes()[0]!.url).searchParams.get( + new globalThis.URL(writes()[0].url).searchParams.get( "expectedExternalIssueUrl", ), ).toBe(url); @@ -506,7 +506,7 @@ describe("app issue-link action", () => { }); await linkAppIssue(prepared); expect( - new globalThis.URL(writes()[0]!.url).searchParams.get( + new globalThis.URL(writes()[0].url).searchParams.get( "expectedExternalIssueUrl", ), ).toBe(URL); diff --git a/packages/cli/test/lib/api/issues.test.ts b/packages/cli/test/lib/api/issues.test.ts index 9d832eb52..34b46ac83 100644 --- a/packages/cli/test/lib/api/issues.test.ts +++ b/packages/cli/test/lib/api/issues.test.ts @@ -175,7 +175,7 @@ describe("mergeIssues", () => { let capturedBody: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; capturedMethod = req.method; capturedBody = await req.json(); diff --git a/packages/cli/test/lib/api/logs.test.ts b/packages/cli/test/lib/api/logs.test.ts index 31e9e4031..e993d5024 100644 --- a/packages/cli/test/lib/api/logs.test.ts +++ b/packages/cli/test/lib/api/logs.test.ts @@ -218,7 +218,7 @@ describe("listLogs", () => { let call = 0; globalThis.fetch = mockFetch(async (input: RequestInfo | URL) => { urls.push(typeof input === "string" ? input : (input as Request).url); - const resp = responses[call]!; + const resp = responses[call]; call += 1; return new Response(JSON.stringify(resp.body), { status: 200, @@ -297,7 +297,7 @@ describe("getLogs", () => { ); expect(url.searchParams.get("project")).toBeNull(); expect(url.searchParams.getAll("field")).toEqual( - requests[0]!.searchParams.getAll("field"), + requests[0].searchParams.getAll("field"), ); } }); @@ -333,21 +333,21 @@ describe("getLogs", () => { expect(logs).toEqual([found, missing]); expect(requests).toHaveLength(2); const [initial, retry] = requests; - expect(initial!.searchParams.get("sampling")).toBe("NORMAL"); - expect(initial!.searchParams.get("start")).toBe("2026-10-08T11:55:00.000Z"); - expect(initial!.searchParams.get("end")).toBe("2026-10-09T12:05:00.000Z"); - expect(retry!.searchParams.get("sampling")).toBe("HIGHEST_ACCURACY"); - expect(retry!.searchParams.get("query")).toBe( + expect(initial.searchParams.get("sampling")).toBe("NORMAL"); + expect(initial.searchParams.get("start")).toBe("2026-10-08T11:55:00.000Z"); + expect(initial.searchParams.get("end")).toBe("2026-10-09T12:05:00.000Z"); + expect(retry.searchParams.get("sampling")).toBe("HIGHEST_ACCURACY"); + expect(retry.searchParams.get("query")).toBe( `sentry.item_id:[${missing["sentry.item_id"]}]`, ); - expect(retry!.searchParams.get("per_page")).toBe("1"); - expect(retry!.searchParams.get("start")).toBe("2026-10-09T11:55:00.000Z"); - expect(retry!.searchParams.get("end")).toBe("2026-10-09T12:05:00.000Z"); + expect(retry.searchParams.get("per_page")).toBe("1"); + expect(retry.searchParams.get("start")).toBe("2026-10-09T11:55:00.000Z"); + expect(retry.searchParams.get("end")).toBe("2026-10-09T12:05:00.000Z"); for (const url of requests) { expect(url.searchParams.get("project")).toBe("4242"); expect(url.searchParams.getAll("field")).toContain("custom.attribute"); expect(url.searchParams.getAll("field")).toEqual( - initial!.searchParams.getAll("field"), + initial.searchParams.getAll("field"), ); expect(url.searchParams.get("statsPeriod")).toBeNull(); } @@ -376,7 +376,7 @@ describe("getLogs", () => { expect(await getLogs("test-org", "test-project", [id, id])).toEqual(data); expect(requests).toHaveLength(1); - expect(requests[0]!.searchParams.get("sampling")).toBe("NORMAL"); + expect(requests[0].searchParams.get("sampling")).toBe("NORMAL"); }); test("stops after one accuracy retry even if the scan remains partial", async () => { diff --git a/packages/cli/test/lib/api/project-dsns.test.ts b/packages/cli/test/lib/api/project-dsns.test.ts index 19ba613f2..8a7484797 100644 --- a/packages/cli/test/lib/api/project-dsns.test.ts +++ b/packages/cli/test/lib/api/project-dsns.test.ts @@ -62,7 +62,7 @@ function mockKeys(respond: (url: URL) => Response) { const requests: Request[] = []; const projectIds: string[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const request = new Request(input!, init); + const request = new Request(input, init); const url = new URL(request.url); const id = /\/projects\/test-org\/(42|7)\/$/.exec(url.pathname)?.[1]; if (id) { @@ -121,7 +121,7 @@ describe.each([ const result = await list(); expect(requests).toHaveLength(1); - const request = requests[0]!; + const request = requests[0]; expect(request.method).toBe("GET"); expect(request.headers.get("Authorization")).toBe("Bearer test-token"); const url = new URL(request.url); @@ -191,7 +191,7 @@ describe.each([ test("org metadata lookup failures surface instead of dropping keys or exposing IDs", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); if (url.pathname === "/api/0/organizations/test-org/project-keys/") { return keysResponse([projectKey()]); } diff --git a/packages/cli/test/lib/api/projects.test.ts b/packages/cli/test/lib/api/projects.test.ts index 43d2555a7..25a9a1df8 100644 --- a/packages/cli/test/lib/api/projects.test.ts +++ b/packages/cli/test/lib/api/projects.test.ts @@ -145,7 +145,7 @@ function mockCreateAndKeysFlow(options?: { }): typeof fetch { let callIndex = 0; return mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); callIndex += 1; // First call: POST to create the project @@ -256,7 +256,7 @@ describe("createProjectWithDsn", () => { }); } - const req = new Request(input!, init); + const req = new Request(input, init); if (callIndex === 2) { return new Response(JSON.stringify([SAMPLE_KEY]), { status: 200, diff --git a/packages/cli/test/lib/api/releases.test.ts b/packages/cli/test/lib/api/releases.test.ts index 39a03d721..02c88e638 100644 --- a/packages/cli/test/lib/api/releases.test.ts +++ b/packages/cli/test/lib/api/releases.test.ts @@ -129,7 +129,7 @@ afterEach(() => { describe("getRelease", () => { test("fetches a release by version", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/releases/1.0.0/"); return new Response(JSON.stringify(SAMPLE_RELEASE), { status: 200, @@ -152,7 +152,7 @@ describe("getRelease", () => { describe("createRelease", () => { test("creates a release with version and projects", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("POST"); const body = (await req.json()) as { version: string; @@ -184,7 +184,7 @@ describe("updateRelease", () => { test("updates a release with dateReleased", async () => { const updated = { ...SAMPLE_RELEASE, dateReleased: "2025-06-15T00:00:00Z" }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("PUT"); expect(req.url).toContain("/releases/1.0.0/"); const body = (await req.json()) as { dateReleased: string }; @@ -210,7 +210,7 @@ describe("updateRelease", () => { describe("deleteRelease", () => { test("deletes a release", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("DELETE"); expect(req.url).toContain("/releases/1.0.0/"); return new Response(null, { status: 204 }); @@ -228,7 +228,7 @@ describe("deleteRelease", () => { describe("listReleaseDeploys", () => { test("returns deploys for a release", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/releases/1.0.0/deploys/"); return new Response(JSON.stringify([SAMPLE_DEPLOY]), { status: 200, @@ -251,7 +251,7 @@ describe("listReleaseDeploys", () => { describe("createReleaseDeploy", () => { test("creates a deploy for a release", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("POST"); expect(req.url).toContain("/releases/1.0.0/deploys/"); const body = (await req.json()) as { environment: string }; @@ -297,7 +297,7 @@ describe("setCommitsAuto", () => { const requests: { method: string; url: string }[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); requests.push({ method: req.method, url: req.url }); // List org repositories (SDK uses /repos/ endpoint) @@ -361,7 +361,7 @@ describe("setCommitsAuto", () => { let reposResolved = false; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.url.includes("/repos/")) { await reposGate; @@ -451,7 +451,7 @@ describe("setCommitsAuto", () => { async ({ body, status }) => { const requests: { method: string; pathname: string }[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const request = new Request(input!, init); + const request = new Request(input, init); requests.push({ method: request.method, pathname: new URL(request.url).pathname, @@ -495,7 +495,7 @@ describe("setCommitsAuto", () => { const repoQueries: (string | null)[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); if (!url.pathname.endsWith("/repos/")) { // Concurrent previous-release lookup return new Response(JSON.stringify({}), { @@ -550,7 +550,7 @@ describe("setCommitsAuto", () => { let repoRequestCount = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.url.includes("/repos/")) { repoRequestCount += 1; @@ -668,7 +668,7 @@ describe("setCommitsAuto", () => { let sentRefs: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.url.includes("/repos/")) { repoQueries.push(new URL(req.url).searchParams.get("query")); return new Response(JSON.stringify([SAMPLE_REPO]), { @@ -732,7 +732,7 @@ describe("setCommitsAuto", () => { let sentRefs: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.url.includes("/repos/")) { const query = new URL(req.url).searchParams.get("query"); repoQueries.push(query); @@ -777,7 +777,7 @@ describe("setCommitsAuto", () => { url: "https://github.com/getsentry/cli-legacy", }; globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); if (!url.pathname.endsWith("/repos/")) { return new Response(JSON.stringify({}), { status: 200, @@ -827,7 +827,7 @@ describe("setCommitsAuto", () => { let sentRefs: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.url.includes("/repos/")) { const query = new URL(req.url).searchParams.get("query") ?? ""; repoQueries.push(query); @@ -886,7 +886,7 @@ describe("setCommitsAuto", () => { let sentRefs: unknown; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); if (req.url.includes("/repos/")) { const query = new URL(req.url).searchParams.get("query") ?? ""; const repos = hits @@ -949,7 +949,7 @@ describe("setCommitsWithRefs", () => { test("keeps a slash in a release version within the org release endpoint", async () => { const requestPaths: string[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const request = new Request(input!, init); + const request = new Request(input, init); requestPaths.push(new URL(request.url).pathname); return new Response(JSON.stringify(SAMPLE_RELEASE), { status: 200, @@ -1228,7 +1228,7 @@ describe("setCommitsLocal", () => { test("sends explicit commits to the API", async () => { const withCommits = { ...SAMPLE_RELEASE, commitCount: 2 }; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.method).toBe("PUT"); const body = (await req.json()) as { commits: Array<{ id: string; message: string }>; @@ -1262,7 +1262,7 @@ describe("setCommitsLocal", () => { describe("listReleasesPaginated", () => { test("returns a page of releases with cursor", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); expect(req.url).toContain("/releases/"); return new Response(JSON.stringify([SAMPLE_RELEASE]), { status: 200, @@ -1300,7 +1300,7 @@ describe("listReleasesPaginated", () => { test("passes query and sort options", async () => { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); const url = new URL(req.url); expect(url.searchParams.get("query")).toBe("1.0"); expect(url.searchParams.get("sort")).toBe("date"); @@ -1323,7 +1323,7 @@ describe("listReleasesPaginated", () => { async (sort) => { let flatten: string | null = null; globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); flatten = url.searchParams.get("flatten"); // Sentry rejects session sorts unless the results are flattened. if (flatten !== "1") { @@ -1351,7 +1351,7 @@ describe("listReleasesPaginated", () => { test("does not flatten date-sorted results", async () => { let flatten: string | null = "unset"; globalThis.fetch = mockFetch(async (input, init) => { - const url = new URL(new Request(input!, init).url); + const url = new URL(new Request(input, init).url); flatten = url.searchParams.get("flatten"); return new Response(JSON.stringify([]), { status: 200, diff --git a/packages/cli/test/lib/api/replays.test.ts b/packages/cli/test/lib/api/replays.test.ts index a3346e9a0..9855e8b02 100644 --- a/packages/cli/test/lib/api/replays.test.ts +++ b/packages/cli/test/lib/api/replays.test.ts @@ -67,7 +67,7 @@ describe("listReplays", () => { let capturedUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; const data = Array.from({ length: 25 }, () => replayRow()); return new Response(JSON.stringify({ data }), { @@ -104,7 +104,7 @@ describe("listReplays", () => { let capturedUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; return new Response(JSON.stringify({ data: [replayRow()] }), { status: 200, @@ -133,7 +133,7 @@ describe("listReplays", () => { let callIndex = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); const body = @@ -191,7 +191,7 @@ describe("getReplay", () => { let capturedUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; return new Response(JSON.stringify({ data: replayRow() }), { status: 200, @@ -270,7 +270,7 @@ describe("resolveReplay", () => { const capturedUrls: string[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); return jsonResponse({ data: replayRow() }); }); @@ -288,7 +288,7 @@ describe("resolveReplay", () => { const capturedUrls: string[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); const url = new URL(req.url); @@ -311,7 +311,7 @@ describe("resolveReplay", () => { expect(replay.id).toBe(REPLAY_ID); expect(capturedUrls).toHaveLength(3); - const listUrl = new URL(capturedUrls[1]!); + const listUrl = new URL(capturedUrls[1]); expect(listUrl.pathname).toContain( "/api/0/organizations/test-org/replays/", ); @@ -327,7 +327,7 @@ describe("resolveReplay", () => { const capturedUrls: string[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); const url = new URL(req.url); @@ -346,7 +346,7 @@ describe("resolveReplay", () => { detail: "Replay not found", }); - const listUrl = new URL(capturedUrls[1]!); + const listUrl = new URL(capturedUrls[1]); expect(listUrl.searchParams.get("query")).toBe(`trace:${TRACE_ID}`); expect(listUrl.searchParams.get("project")).toBe("-1"); expect(listUrl.searchParams.get("projectSlug")).toBeNull(); @@ -356,7 +356,7 @@ describe("resolveReplay", () => { const capturedUrls: string[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); return jsonResponse({ detail: "Bad Request" }, 400); }); @@ -387,7 +387,7 @@ describe("getReplayRecordingSegments", () => { let capturedUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; return recordingSegmentsResponse([[{ timestamp: 1 }]]); }); @@ -422,7 +422,7 @@ describe("getReplayRecordingSegments", () => { let callIndex = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); const body = @@ -445,11 +445,11 @@ describe("getReplayRecordingSegments", () => { expect(segments).toHaveLength(101); expect(capturedUrls).toHaveLength(2); - const firstUrl = new URL(capturedUrls[0]!); + const firstUrl = new URL(capturedUrls[0]); expect(firstUrl.searchParams.get("per_page")).toBe("100"); expect(firstUrl.searchParams.get("cursor")).toBeNull(); - const secondUrl = new URL(capturedUrls[1]!); + const secondUrl = new URL(capturedUrls[1]); expect(secondUrl.searchParams.get("cursor")).toBe("0:100:0"); expect(secondUrl.searchParams.get("per_page")).toBe("100"); }); @@ -460,7 +460,7 @@ describe("getReplayRecordingSegments", () => { let callIndex = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); const nextCursor = `0:${(callIndex + 1) * 100}:0`; @@ -507,7 +507,7 @@ describe("listReplayIdsForIssue", () => { let capturedUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; return new Response( JSON.stringify({ diff --git a/packages/cli/test/lib/api/trace-item-attributes.test.ts b/packages/cli/test/lib/api/trace-item-attributes.test.ts index 1d96de763..73debe036 100644 --- a/packages/cli/test/lib/api/trace-item-attributes.test.ts +++ b/packages/cli/test/lib/api/trace-item-attributes.test.ts @@ -37,7 +37,7 @@ let capturedUrl: URL | undefined; function mockOk(body: unknown, headers: Record = {}) { globalThis.fetch = mockFetch(async (input, init) => { - capturedUrl = new URL(new Request(input!, init).url); + capturedUrl = new URL(new Request(input, init).url); return Response.json(body, { headers }); }); } diff --git a/packages/cli/test/lib/api/traces.test.ts b/packages/cli/test/lib/api/traces.test.ts index 89b0c7463..d550e1d96 100644 --- a/packages/cli/test/lib/api/traces.test.ts +++ b/packages/cli/test/lib/api/traces.test.ts @@ -40,7 +40,7 @@ describe("listTransactions", () => { function mockOk(body: unknown, headers: Record = {}) { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; capturedMethod = req.method; return new Response(JSON.stringify(body), { @@ -61,10 +61,10 @@ describe("listTransactions", () => { let callIndex = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); - const resp = responses[callIndex]!; + const resp = responses[callIndex]; callIndex += 1; return new Response(JSON.stringify(resp.body), { @@ -305,7 +305,7 @@ describe("listSpans", () => { function mockOk(body: unknown, headers: Record = {}) { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; capturedMethod = req.method; return new Response(JSON.stringify(body), { @@ -322,10 +322,10 @@ describe("listSpans", () => { let callIndex = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); - const resp = responses[callIndex]!; + const resp = responses[callIndex]; callIndex += 1; return new Response(JSON.stringify(resp.body), { @@ -591,7 +591,7 @@ describe("getSpanDetails", () => { function mockOk(body: unknown) { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrl = req.url; const url = new URL(capturedUrl); url.searchParams.forEach((v, k) => { @@ -689,7 +689,7 @@ describe("fetchMultiSpanDetails", () => { function mockOk() { globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); requestedUrls.push(req.url); return new Response( JSON.stringify({ @@ -780,7 +780,7 @@ describe("getDetailedTrace", () => { let callIndex = 0; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); capturedUrls.push(req.url); const body = bodies[callIndex] ?? []; callIndex += 1; @@ -801,9 +801,9 @@ describe("getDetailedTrace", () => { }); expect(result).toHaveLength(1); - expect(result[0]!.span_id).toBe("span-1"); + expect(result[0].span_id).toBe("span-1"); expect(getCapturedUrls()).toHaveLength(1); - const url = new URL(getCapturedUrls()[0]!); + const url = new URL(getCapturedUrls()[0]); expect(url.searchParams.get("timestamp")).toBe("1700000000"); expect(url.searchParams.get("statsPeriod")).toBeNull(); expect(url.searchParams.has("limit")).toBe(false); @@ -817,7 +817,7 @@ describe("getDetailedTrace", () => { expect(result).toHaveLength(1); expect(getCapturedUrls()).toHaveLength(1); - const url = new URL(getCapturedUrls()[0]!); + const url = new URL(getCapturedUrls()[0]); expect(url.searchParams.get("statsPeriod")).toBe("14d"); expect(url.searchParams.get("timestamp")).toBeNull(); }); @@ -828,19 +828,19 @@ describe("getDetailedTrace", () => { const result = await getDetailedTrace("my-org", "abc123def456"); expect(result).toHaveLength(1); - expect(result[0]!.span_id).toBe("span-1"); + expect(result[0].span_id).toBe("span-1"); expect(getCapturedUrls()).toHaveLength(2); - expect(new URL(getCapturedUrls()[0]!).searchParams.get("statsPeriod")).toBe( + expect(new URL(getCapturedUrls()[0]).searchParams.get("statsPeriod")).toBe( "14d", ); - expect(new URL(getCapturedUrls()[1]!).searchParams.get("statsPeriod")).toBe( + expect(new URL(getCapturedUrls()[1]).searchParams.get("statsPeriod")).toBe( "90d", ); expect( - new URL(getCapturedUrls()[0]!).searchParams.get("timestamp"), + new URL(getCapturedUrls()[0]).searchParams.get("timestamp"), ).toBeNull(); expect( - new URL(getCapturedUrls()[1]!).searchParams.get("timestamp"), + new URL(getCapturedUrls()[1]).searchParams.get("timestamp"), ).toBeNull(); }); @@ -853,11 +853,11 @@ describe("getDetailedTrace", () => { expect(result).toHaveLength(0); expect(getCapturedUrls()).toHaveLength(1); - expect(new URL(getCapturedUrls()[0]!).searchParams.get("timestamp")).toBe( + expect(new URL(getCapturedUrls()[0]).searchParams.get("timestamp")).toBe( "1700000000", ); expect( - new URL(getCapturedUrls()[0]!).searchParams.get("statsPeriod"), + new URL(getCapturedUrls()[0]).searchParams.get("statsPeriod"), ).toBeNull(); }); diff --git a/packages/cli/test/lib/app-scope-recovery.test.ts b/packages/cli/test/lib/app-scope-recovery.test.ts index 73bada980..1786064ae 100644 --- a/packages/cli/test/lib/app-scope-recovery.test.ts +++ b/packages/cli/test/lib/app-scope-recovery.test.ts @@ -27,11 +27,11 @@ afterEach(() => { describe("scope-recovery error boundary", () => { test.each([401, 403])("lets API %i escape Stricli", async (status) => { - globalThis.fetch = (async () => + globalThis.fetch = async () => new Response(JSON.stringify({ detail: "Denied" }), { status, headers: { "content-type": "application/json" }, - })) as typeof fetch; + }); let thrown: unknown; try { diff --git a/packages/cli/test/lib/bench/helpers.test.ts b/packages/cli/test/lib/bench/helpers.test.ts index ec1665d8a..53fe9fbe8 100644 --- a/packages/cli/test/lib/bench/helpers.test.ts +++ b/packages/cli/test/lib/bench/helpers.test.ts @@ -171,10 +171,10 @@ describe("compareReports", () => { ...baseline, entries: [ { - ...baseline.entries[0]!, - stats: { ...baseline.entries[0]!.stats, p50: 15 }, + ...baseline.entries[0], + stats: { ...baseline.entries[0].stats, p50: 15 }, }, - baseline.entries[1]!, + baseline.entries[1], ], }; const rows = compareReports(baseline, current, 0.2); @@ -189,10 +189,10 @@ describe("compareReports", () => { ...baseline, entries: [ { - ...baseline.entries[0]!, - stats: { ...baseline.entries[0]!.stats, p50: 7 }, + ...baseline.entries[0], + stats: { ...baseline.entries[0].stats, p50: 7 }, }, - baseline.entries[1]!, + baseline.entries[1], ], }; const rows = compareReports(baseline, current, 0.2); @@ -203,7 +203,7 @@ describe("compareReports", () => { test("reports missing current entry when op disappears", () => { const current: BenchReport = { ...baseline, - entries: [baseline.entries[1]!], + entries: [baseline.entries[1]], }; const rows = compareReports(baseline, current, 0.2); const cold = rows.find((r) => r.operation === "detectDsn.cold"); diff --git a/packages/cli/test/lib/binary.test.ts b/packages/cli/test/lib/binary.test.ts index eb5262d9a..7504f515f 100644 --- a/packages/cli/test/lib/binary.test.ts +++ b/packages/cli/test/lib/binary.test.ts @@ -429,8 +429,7 @@ describe("fetchWithUpgradeError", () => { }); test("returns response on success", async () => { - globalThis.fetch = (async () => - new Response("ok", { status: 200 })) as typeof globalThis.fetch; + globalThis.fetch = async () => new Response("ok", { status: 200 }); const response = await fetchWithUpgradeError( "https://example.com", @@ -441,11 +440,11 @@ describe("fetchWithUpgradeError", () => { }); test("re-throws AbortError as-is", async () => { - globalThis.fetch = (async () => { + globalThis.fetch = async () => { const err = new Error("Aborted"); err.name = "AbortError"; throw err; - }) as typeof globalThis.fetch; + }; try { await fetchWithUpgradeError("https://example.com", {}, "Test"); @@ -473,9 +472,9 @@ describe("fetchWithUpgradeError", () => { }); test("wraps network errors as UpgradeError", async () => { - globalThis.fetch = (async () => { + globalThis.fetch = async () => { throw new Error("ECONNREFUSED"); - }) as typeof globalThis.fetch; + }; try { await fetchWithUpgradeError("https://example.com", {}, "GitHub"); @@ -488,10 +487,10 @@ describe("fetchWithUpgradeError", () => { }); test("wraps non-Error thrown values as UpgradeError", async () => { - globalThis.fetch = (async () => { + globalThis.fetch = async () => { // intentionally testing non-Error throw throw { code: "ECONNRESET", reason: "connection reset" }; - }) as typeof globalThis.fetch; + }; try { await fetchWithUpgradeError("https://example.com", {}, "Service"); diff --git a/packages/cli/test/lib/bootstrap-auth.test.ts b/packages/cli/test/lib/bootstrap-auth.test.ts index cf9c03ea3..538a84ddb 100644 --- a/packages/cli/test/lib/bootstrap-auth.test.ts +++ b/packages/cli/test/lib/bootstrap-auth.test.ts @@ -122,7 +122,7 @@ test("uses explicit proxy headers for a new server while preserving the old logi await expect( bootstrapAuthentication({ force: true, url: host }), ).rejects.toThrow(/Setup-code/); - expect(fetch.mock.calls[0]![1].headers.get("X-IAP-Token")).toBe( + expect(fetch.mock.calls[0][1].headers.get("X-IAP-Token")).toBe( "proxy-secret", ); expect(getAuthConfig()?.token).toBe("old-server-token"); @@ -194,7 +194,7 @@ test.each([ ); expect(fetch).toHaveBeenCalledOnce(); - expect(fetch.mock.calls[0]![1].headers.get("X-IAP-Token")).toBe( + expect(fetch.mock.calls[0][1].headers.get("X-IAP-Token")).toBe( trusted ? "proxy-secret" : null, ); }, diff --git a/packages/cli/test/lib/build/dsyms.test.ts b/packages/cli/test/lib/build/dsyms.test.ts index b3ec8a3c0..815fc0275 100644 --- a/packages/cli/test/lib/build/dsyms.test.ts +++ b/packages/cli/test/lib/build/dsyms.test.ts @@ -60,7 +60,7 @@ describe("collectDsymEntries", () => { test("collects a direct bundle's files for streaming", async () => { const entries = await collect([await bundle()]); expect(entries.map((entry) => entry.relPath)).toEqual([ZIP_SYMBOL_PATH]); - expect(await readFile(entries[0]!.sourcePath, "utf8")).toBe("symbols"); + expect(await readFile(entries[0].sourcePath, "utf8")).toBe("symbols"); }); test("recognizes a direct bundle with trailing slashes", async () => { @@ -96,9 +96,7 @@ describe("collectDsymEntries", () => { ); const entries = await collect([path]); expect(entries.map((entry) => entry.relPath)).toEqual([ZIP_SYMBOL_PATH]); - expect(await readFile(entries[0]!.sourcePath, "utf8")).toBe( - "zip symbols", - ); + expect(await readFile(entries[0].sourcePath, "utf8")).toBe("zip symbols"); }, ); @@ -145,7 +143,7 @@ describe("collectDsymEntries", () => { zipSync({ [ZIP_SYMBOL_PATH]: symbols }, { level }), ); const entries = await collect([path]); - expect(await readFile(entries[0]!.sourcePath)).toEqual( + expect(await readFile(entries[0].sourcePath)).toEqual( Buffer.from(symbols), ); }, diff --git a/packages/cli/test/lib/checkin-builder.property.test.ts b/packages/cli/test/lib/checkin-builder.property.test.ts index 64d36e10d..4eb304009 100644 --- a/packages/cli/test/lib/checkin-builder.property.test.ts +++ b/packages/cli/test/lib/checkin-builder.property.test.ts @@ -126,7 +126,7 @@ describe("property: buildCheckIn", () => { const checkIn = buildCheckIn({ checkInId, monitorSlug, - status: status as "in_progress" | "ok" | "error", + status: status, }); expect(checkIn.check_in_id).toBe(checkInId); expect(checkIn.monitor_slug).toBe(monitorSlug); diff --git a/packages/cli/test/lib/chunk-loader.test.ts b/packages/cli/test/lib/chunk-loader.test.ts index 33e200872..15bce9e14 100644 --- a/packages/cli/test/lib/chunk-loader.test.ts +++ b/packages/cli/test/lib/chunk-loader.test.ts @@ -281,8 +281,7 @@ describe("createChunkLoader", () => { { "cli.cjs": "exports.os = import('node:os');" }, undefined, ); - const os = (await (exports as { os: Promise }) - .os) as typeof import("node:os"); + const os = await (exports as { os: Promise }).os; expect(typeof os.tmpdir).toBe("function"); }); diff --git a/packages/cli/test/lib/command-auth-guard.test.ts b/packages/cli/test/lib/command-auth-guard.test.ts index d89d8f3ee..f02754d7f 100644 --- a/packages/cli/test/lib/command-auth-guard.test.ts +++ b/packages/cli/test/lib/command-auth-guard.test.ts @@ -71,7 +71,7 @@ async function runTargeting(org: string): Promise { await run(app, ["cmd"], { process: { stdout, stderr: { write } }, stdout, - } as unknown as TestContext); + }); return seen.length > 0 ? (seen[0] ?? "") : undefined; } diff --git a/packages/cli/test/lib/completion-warmup.test.ts b/packages/cli/test/lib/completion-warmup.test.ts index b652fcb13..a674ead02 100644 --- a/packages/cli/test/lib/completion-warmup.test.ts +++ b/packages/cli/test/lib/completion-warmup.test.ts @@ -69,7 +69,7 @@ function mockAttributes( respond: (request: Captured, init?: RequestInit) => Promise, ): void { globalThis.fetch = mockFetch(async (input, init) => { - const request = new Request(input!, init); + const request = new Request(input, init); const url = new URL(request.url); const captured = { org: url.pathname.split("/")[4] ?? "", diff --git a/packages/cli/test/lib/custom-ca.test.ts b/packages/cli/test/lib/custom-ca.test.ts index 4cd27eedc..06fff7ac2 100644 --- a/packages/cli/test/lib/custom-ca.test.ts +++ b/packages/cli/test/lib/custom-ca.test.ts @@ -392,10 +392,10 @@ describe("customFetch", () => { test("calls fetch without tls option when no custom CA", async () => { let capturedInit: RequestInit | undefined; - globalThis.fetch = ((_input: unknown, init?: RequestInit) => { + globalThis.fetch = (_input: unknown, init?: RequestInit) => { capturedInit = init; return Promise.resolve(new Response("ok")); - }) as typeof fetch; + }; await customFetch("https://example.com", { headers: { "X-Test": "1" } }); expect(capturedInit).toBeDefined(); @@ -409,10 +409,10 @@ describe("customFetch", () => { process.env.NODE_EXTRA_CA_CERTS = certPath; let capturedInit: Record | undefined; - globalThis.fetch = ((_input: unknown, init?: RequestInit) => { + globalThis.fetch = (_input: unknown, init?: RequestInit) => { capturedInit = init as Record; return Promise.resolve(new Response("ok")); - }) as typeof fetch; + }; await customFetch("https://example.com", { headers: { "X-Test": "1" } }); expect(capturedInit).toBeDefined(); @@ -427,10 +427,10 @@ describe("customFetch", () => { process.env.NODE_EXTRA_CA_CERTS = certPath; let capturedInit: Record | undefined; - globalThis.fetch = ((_input: unknown, init?: RequestInit) => { + globalThis.fetch = (_input: unknown, init?: RequestInit) => { capturedInit = init as Record; return Promise.resolve(new Response("ok")); - }) as typeof fetch; + }; await customFetch("https://example.com", { method: "POST", diff --git a/packages/cli/test/lib/db/model-based.test.ts b/packages/cli/test/lib/db/model-based.test.ts index 955afeaeb..a8ccc2121 100644 --- a/packages/cli/test/lib/db/model-based.test.ts +++ b/packages/cli/test/lib/db/model-based.test.ts @@ -214,7 +214,7 @@ class GetAuthConfigCommand implements AsyncCommand { expect(realConfig?.token).toBe(model.auth.token as string); expect(realConfig?.source).toBe("oauth"); expect(realConfig?.refreshToken).toBe( - (model.auth.refreshToken ?? undefined) as string | undefined, + model.auth.refreshToken ?? undefined, ); if (model.auth.expiresAt !== null) { expect(realConfig?.expiresAt).toBeDefined(); diff --git a/packages/cli/test/lib/db/pagination.model-based.test.ts b/packages/cli/test/lib/db/pagination.model-based.test.ts index bd906c9de..c3859e93a 100644 --- a/packages/cli/test/lib/db/pagination.model-based.test.ts +++ b/packages/cli/test/lib/db/pagination.model-based.test.ts @@ -119,7 +119,7 @@ class AdvanceNextCommand implements AsyncCommand { const real = getPaginationState(CMD_KEY, CTX_KEY); expect(real).toBeDefined(); expect(real!.stack).toEqual(model.stack); - expect(real!.index).toBe(model.index!); + expect(real!.index).toBe(model.index); } toString(): string { diff --git a/packages/cli/test/lib/db/repo-cache.test.ts b/packages/cli/test/lib/db/repo-cache.test.ts index 89e5dc48b..0945c13da 100644 --- a/packages/cli/test/lib/db/repo-cache.test.ts +++ b/packages/cli/test/lib/db/repo-cache.test.ts @@ -26,7 +26,7 @@ function makeRepo(name: string): SentryRepository { provider: { id: "integrations:github", name: "GitHub" }, status: "active", externalSlug: name, - } as SentryRepository; + }; } afterEach(() => { diff --git a/packages/cli/test/lib/db/schema-downgrade.focused.test.ts b/packages/cli/test/lib/db/schema-downgrade.focused.test.ts index cbecdd7b7..2f87be416 100644 --- a/packages/cli/test/lib/db/schema-downgrade.focused.test.ts +++ b/packages/cli/test/lib/db/schema-downgrade.focused.test.ts @@ -253,7 +253,7 @@ describe("prepareDatabaseForDowngrade", () => { const db = getRawDatabase(); prepareDatabaseForDowngrade(db); // An older CLI between schema 16 and this one migrates forward on setup. - db.exec(EXPECTED_TABLES.org_regions as string); + db.exec(EXPECTED_TABLES.org_regions); db.query("UPDATE schema_version SET version = ?").run( CURRENT_SCHEMA_VERSION - 1, ); diff --git a/packages/cli/test/lib/db/schema.test.ts b/packages/cli/test/lib/db/schema.test.ts index e328c5533..9c5b829d6 100644 --- a/packages/cli/test/lib/db/schema.test.ts +++ b/packages/cli/test/lib/db/schema.test.ts @@ -32,7 +32,7 @@ function createDatabaseWithMissingTables( const statements: string[] = []; for (const tableName of Object.keys(EXPECTED_TABLES)) { if (missingTables.includes(tableName)) continue; - statements.push(EXPECTED_TABLES[tableName] as string); + statements.push(EXPECTED_TABLES[tableName]); } db.exec(statements.join(";\n")); db.query("INSERT INTO schema_version (version) VALUES (?)").run( @@ -53,7 +53,7 @@ function createPreMigrationDatabase( if (preMigrationTables.includes(tableName)) { statements.push(generatePreMigrationTableDDL(tableName)); } else { - statements.push(EXPECTED_TABLES[tableName] as string); + statements.push(EXPECTED_TABLES[tableName]); } } db.exec(statements.join(";\n")); diff --git a/packages/cli/test/lib/delta-upgrade.mocked.test.ts b/packages/cli/test/lib/delta-upgrade.mocked.test.ts index 0131a923a..59d514bf9 100644 --- a/packages/cli/test/lib/delta-upgrade.mocked.test.ts +++ b/packages/cli/test/lib/delta-upgrade.mocked.test.ts @@ -64,7 +64,7 @@ afterEach(() => { function mockFetch( fn: (url: string | URL | Request, init?: RequestInit) => Promise, ): void { - globalThis.fetch = fn as typeof globalThis.fetch; + globalThis.fetch = fn; } // ============================================================================ @@ -150,7 +150,7 @@ describe("resolveStableDelta", () => { return new Response(JSON.stringify(releases), { status: 200 }); } if (urlStr === patchUrl) { - return new Response(emptyTrdiff10.buffer as ArrayBuffer, { + return new Response(emptyTrdiff10.buffer, { status: 200, }); } @@ -393,12 +393,9 @@ describe("attemptDeltaUpgrade", () => { return new Response(JSON.stringify(releases), { status: 200 }); } if (urlStr === patchUrl) { - return new Response( - new Uint8Array([0, 1, 2, 3]).buffer as ArrayBuffer, - { - status: 200, - }, - ); + return new Response(new Uint8Array([0, 1, 2, 3]).buffer, { + status: 200, + }); } return new Response("Not Found", { status: 404 }); }); diff --git a/packages/cli/test/lib/delta-upgrade.test.ts b/packages/cli/test/lib/delta-upgrade.test.ts index 3d56f96c0..77b31e15b 100644 --- a/packages/cli/test/lib/delta-upgrade.test.ts +++ b/packages/cli/test/lib/delta-upgrade.test.ts @@ -811,7 +811,7 @@ describe("validateChainStep", () => { function mockFetch( fn: (url: string | URL | Request, init?: RequestInit) => Promise, ): void { - globalThis.fetch = fn as typeof globalThis.fetch; + globalThis.fetch = fn; } /** Store original fetch for restoration */ @@ -909,7 +909,7 @@ describe("downloadStablePatch", () => { mockFetch(async (url) => { expect(extractInputUrl(url)).toBe("https://example.com/patch.bin"); - return new Response(patchData.buffer as ArrayBuffer, { + return new Response(patchData.buffer, { status: 200, }); }); diff --git a/packages/cli/test/lib/detect-agent.test.ts b/packages/cli/test/lib/detect-agent.test.ts index 7e80e79c3..d6456a88a 100644 --- a/packages/cli/test/lib/detect-agent.test.ts +++ b/packages/cli/test/lib/detect-agent.test.ts @@ -19,7 +19,7 @@ function named(name: string): AgentInfo { } function withEnv(vars: Record) { - setEnv(vars as NodeJS.ProcessEnv); + setEnv(vars); } /** No-op async provider typed to satisfy ProcessInfoProvider. */ diff --git a/packages/cli/test/lib/error-reporting.test.ts b/packages/cli/test/lib/error-reporting.test.ts index 975665023..1e6e9e553 100644 --- a/packages/cli/test/lib/error-reporting.test.ts +++ b/packages/cli/test/lib/error-reporting.test.ts @@ -473,7 +473,7 @@ describe("enrichEventWithGroupingTags", () => { test("sets cli_error.kind from exception value", () => { const event = makeEvent("TypeError"); - event.exception!.values![0]!.value = + event.exception!.values![0].value = "Cannot read properties of undefined (reading 'replaceAll')"; const result = enrichEventWithGroupingTags(event); expect(result.tags?.["cli_error.kind"]).toBe("Cannot read properties of"); @@ -481,17 +481,17 @@ describe("enrichEventWithGroupingTags", () => { test("sets cli_error.kind for fetch failed TypeError", () => { const event = makeEvent("TypeError"); - event.exception!.values![0]!.value = "fetch failed"; + event.exception!.values![0].value = "fetch failed"; const result = enrichEventWithGroupingTags(event); expect(result.tags?.["cli_error.kind"]).toBe("fetch failed"); }); test("sets cli_error.kind for Error with variable project count", () => { const event1 = makeEvent("Error"); - event1.exception!.values![0]!.value = + event1.exception!.values![0].value = "Failed to fetch issues from 3 project(s): Failed to list issues: 400 Bad Request"; const event2 = makeEvent("Error"); - event2.exception!.values![0]!.value = + event2.exception!.values![0].value = "Failed to fetch issues from 1 project(s): Failed to list issues: 400 Bad Request"; const result1 = enrichEventWithGroupingTags(event1); const result2 = enrichEventWithGroupingTags(event2); @@ -514,7 +514,7 @@ describe("enrichEventWithGroupingTags", () => { "cli_error.class": "ContextError", "cli_error.kind": "Organization", }); - event.exception!.values![0]!.value = "some different message"; + event.exception!.values![0].value = "some different message"; const result = enrichEventWithGroupingTags(event); expect(result.tags?.["cli_error.kind"]).toBe("Organization"); }); diff --git a/packages/cli/test/lib/formatters/chart-core.test.ts b/packages/cli/test/lib/formatters/chart-core.test.ts index 419f2ddc0..fd4c73404 100644 --- a/packages/cli/test/lib/formatters/chart-core.test.ts +++ b/packages/cli/test/lib/formatters/chart-core.test.ts @@ -134,7 +134,7 @@ describe("buildCategoricalChartModel", () => { describe("rasterizeChart", () => { test("declines dense nullable buckets instead of averaging across gaps", () => { const model = buildChartModel(makeTimeseries())!; - model.series[0]!.values = [10, null, 20, 30, 40, 50, 60, 70, 80]; + model.series[0].values = [10, null, 20, 30, 40, 50, 60, 70, 80]; model.buckets = 9; expect(rasterizeChart(model, { width: 16, height: 8 })).toBeUndefined(); diff --git a/packages/cli/test/lib/formatters/colors.test.ts b/packages/cli/test/lib/formatters/colors.test.ts index 53d4301c1..296e17edb 100644 --- a/packages/cli/test/lib/formatters/colors.test.ts +++ b/packages/cli/test/lib/formatters/colors.test.ts @@ -196,7 +196,7 @@ describe("terminalLink", () => { test("returns plain text without OSC 8 when piped", () => { const savedTTY = process.stdout.isTTY; const savedPlain = process.env.SENTRY_PLAIN_OUTPUT; - process.stdout.isTTY = false as unknown as boolean; + process.stdout.isTTY = false; delete process.env.SENTRY_PLAIN_OUTPUT; try { const result = terminalLink("click me", "https://example.com"); diff --git a/packages/cli/test/lib/formatters/event-outcomes.test.ts b/packages/cli/test/lib/formatters/event-outcomes.test.ts index 81843f224..1ee875904 100644 --- a/packages/cli/test/lib/formatters/event-outcomes.test.ts +++ b/packages/cli/test/lib/formatters/event-outcomes.test.ts @@ -118,7 +118,7 @@ describe("summarizeEventOutcomes", () => { events: 10, tags: [], }); - expect(rows[1]!.outcome).toBe("rate_limited"); + expect(rows[1].outcome).toBe("rate_limited"); }); test("defaults tags to [] when an older server omits them", () => { @@ -137,7 +137,7 @@ describe("summarizeEventOutcomes", () => { const rows = summarizeEventOutcomes(response); - expect(rows[0]!.tags).toEqual([]); + expect(rows[0].tags).toEqual([]); expect(formatEventOutcomes(rows)).toContain("—"); }); }); diff --git a/packages/cli/test/lib/formatters/explore-timeseries.test.ts b/packages/cli/test/lib/formatters/explore-timeseries.test.ts index 3e0a84936..426844ca7 100644 --- a/packages/cli/test/lib/formatters/explore-timeseries.test.ts +++ b/packages/cli/test/lib/formatters/explore-timeseries.test.ts @@ -104,7 +104,7 @@ describe("formatExploreTimeSeriesHuman", () => { test("renders each measure with its own metadata and distinguishes missing values from zero", () => { const data = makeData(); - data.timeSeries[0]!.values.pop(); + data.timeSeries[0].values.pop(); data.timeSeries.push({ yAxis: "p95(span.duration)", meta: { @@ -138,7 +138,7 @@ describe("formatExploreTimeSeriesHuman", () => { test("preserves identifier-like and markdown-like strings without coercion", () => { const data = makeData(); - const series = data.timeSeries[0]!; + const series = data.timeSeries[0]; series.yAxis = "latest_event()"; series.meta.valueType = "string"; series.values = [ @@ -165,7 +165,7 @@ describe("formatExploreTimeSeriesHuman", () => { test("distinguishes retention, unfinished windows, and unavailable scan coverage", () => { const data = makeData(); - const series = data.timeSeries[0]!; + const series = data.timeSeries[0]; series.meta.dataScanned = "partial"; series.values[0] = { timestamp: Date.UTC(2026, 0, 1), @@ -176,7 +176,7 @@ describe("formatExploreTimeSeriesHuman", () => { sampleRate: 0.1, confidence: "low", }; - series.values[2]!.incompleteReason = "NOT_ELAPSED"; + series.values[2].incompleteReason = "NOT_ELAPSED"; const output = formatExploreTimeSeriesHuman(data); @@ -191,7 +191,7 @@ describe("formatExploreTimeSeriesHuman", () => { test("does not mistake absent series or buckets for zero-valued results", () => { const data = makeData(); - data.timeSeries[0]!.values = []; + data.timeSeries[0].values = []; expect(formatExploreTimeSeriesHuman(data)).toContain( "No time buckets returned", ); @@ -292,8 +292,8 @@ describe("Explore time-series graphics", () => { vi.mocked(terminal.selectGraphicsFormat).mockReturnValue(format); vi.stubEnv("TZ", "America/Los_Angeles"); const data = makeData(); - const count = data.timeSeries[0]!; - count.values[2]!.incomplete = false; + const count = data.timeSeries[0]; + count.values[2].incomplete = false; data.timeSeries.push({ yAxis: "p95(span.duration)", meta: { @@ -335,21 +335,19 @@ describe("Explore time-series graphics", () => { expect(data).toEqual(original); if (format === "kitty") { const [countImage, durationImage] = kittyImages(output); - expect(textPixels(countImage!, 0, 0, 5)).toEqual(labelPixels("1,234")); - expect(textPixels(durationImage!, 0, 0, 4)).toEqual( - labelPixels("25ms"), - ); - expect(textPixels(durationImage!, 41, 48, 23)).toEqual( + expect(textPixels(countImage, 0, 0, 5)).toEqual(labelPixels("1,234")); + expect(textPixels(durationImage, 0, 0, 4)).toEqual(labelPixels("25ms")); + expect(textPixels(durationImage, 41, 48, 23)).toEqual( labelPixels("2026-01-01 00:00:00 UTC"), ); - expect(textPixels(durationImage!, 449, 48, 23)).toEqual( + expect(textPixels(durationImage, 449, 48, 23)).toEqual( labelPixels("2026-01-01 00:00:15 UTC"), ); - expect(textPixels(durationImage!, 8, 56, 17)).toEqual( + expect(textPixels(durationImage, 8, 56, 17)).toEqual( labelPixels("p95 span.duration", [224, 224, 224]), ); expect([ - ...durationImage!.data.subarray(58 * 640 * 4, 58 * 640 * 4 + 4), + ...durationImage.data.subarray(58 * 640 * 4, 58 * 640 * 4 + 4), ]).toEqual([117, 83, 255, 255]); } }, @@ -365,7 +363,7 @@ describe("Explore time-series graphics", () => { "retains the complete expression %s below an abbreviated legend", (yAxis) => { const data = makeData(); - data.timeSeries[0]!.yAxis = yAxis; + data.timeSeries[0].yAxis = yAxis; const output = formatExploreTimeSeriesHuman(data); @@ -388,10 +386,10 @@ describe("Explore time-series graphics", () => { "keeps $valueType units in the caption on a narrow chart (maximum $maximum)", ({ valueType, maximum, label }) => { const data = makeData(); - const series = data.timeSeries[0]!; + const series = data.timeSeries[0]; series.meta.valueType = valueType; series.meta.valueUnit = "1/second"; - series.values[0]!.value = maximum; + series.values[0].value = maximum; // A redundant axis unit would consume the space needed by the UTC labels. process.stdout.columns = 56; vi.mocked(terminal.terminalPixelWidth).mockReturnValue(448); @@ -400,7 +398,7 @@ describe("Explore time-series graphics", () => { const images = kittyImages(output); expect(images).toHaveLength(1); - expect(textPixels(images[0]!, 0, 0, label.length)).toEqual( + expect(textPixels(images[0], 0, 0, label.length)).toEqual( labelPixels(label), ); expect(output).toContain("Interval: 5m · Unit: 1/second"); @@ -412,7 +410,7 @@ describe("Explore time-series graphics", () => { test("keeps gaps in place, distinguishes zero, and retains incomplete values and warnings", () => { const data = makeData(); - const series = data.timeSeries[0]!; + const series = data.timeSeries[0]; series.meta.dataScanned = "partial"; series.values = [10_000, null, 0, 90_000, 80_000, 70_000, 5000, 1].map( (value, index) => ({ @@ -421,21 +419,21 @@ describe("Explore time-series graphics", () => { incomplete: false, }), ); - series.values[3]!.incomplete = true; - series.values[3]!.incompleteReason = "OUTSIDE_RETENTION"; - series.values[4]!.incomplete = true; - series.values[4]!.incompleteReason = "INGESTION_PENDING"; - series.values[5]!.incomplete = true; - series.values[5]!.incompleteReason = "NOT_ELAPSED"; - series.values[6]!.sampleRate = 0.1; - series.values[6]!.confidence = "low"; + series.values[3].incomplete = true; + series.values[3].incompleteReason = "OUTSIDE_RETENTION"; + series.values[4].incomplete = true; + series.values[4].incompleteReason = "INGESTION_PENDING"; + series.values[5].incomplete = true; + series.values[5].incompleteReason = "NOT_ELAPSED"; + series.values[6].sampleRate = 0.1; + series.values[6].confidence = "low"; const original = structuredClone(data); const output = formatExploreTimeSeriesHuman(data); const images = kittyImages(output); expect(images).toHaveLength(1); - const image = images[0]!; + const image = images[0]; expect(image.data).toHaveLength(image.width * image.height * 4); // Eight slots follow the value-axis gutter. Gaps keep their time positions // and the axis below the plot must not turn them into visible data ticks. @@ -486,7 +484,7 @@ describe("Explore time-series graphics", () => { test("scales sub-centesimal measurements without labelling them zero", () => { const data = makeData(); - const series = data.timeSeries[0]!; + const series = data.timeSeries[0]; series.meta.valueType = "duration"; series.meta.valueUnit = "millisecond"; series.values = [0.001, 0.002].map((value, index) => ({ @@ -499,23 +497,23 @@ describe("Explore time-series graphics", () => { const [image] = kittyImages(output); expect(image).toBeDefined(); - expect(textPixels(image!, 0, 0, 7)).toEqual(labelPixels("0.002ms")); - expect(alphaAt(image!, 100, 22)).toBe(0); - expect(alphaAt(image!, 100, 23)).toBe(255); - expect(alphaAt(image!, 400, 0)).toBe(255); + expect(textPixels(image, 0, 0, 7)).toEqual(labelPixels("0.002ms")); + expect(alphaAt(image, 100, 22)).toBe(0); + expect(alphaAt(image, 100, 23)).toBe(255); + expect(alphaAt(image, 400, 0)).toBe(255); }); test.each(["negative", "string", "irregular", "missing"] as const)( "uses the table for a %s series", (kind) => { const data = makeData(); - const series = data.timeSeries[0]!; + const series = data.timeSeries[0]; if (kind === "negative") { - series.values[0]!.value = -5; + series.values[0].value = -5; } else if (kind === "string") { - series.values[0]!.value = "00123"; + series.values[0].value = "00123"; } else if (kind === "irregular") { - series.values[1]!.timestamp += 1000; + series.values[1].timestamp += 1000; } else { series.values = series.values.map((bucket) => ({ ...bucket, @@ -538,7 +536,7 @@ describe("Explore time-series graphics", () => { test("uses the full table when axes leave too little plot width for percentile buckets", () => { const data = makeData(); - const series = data.timeSeries[0]!; + const series = data.timeSeries[0]; series.yAxis = "p95(span.duration)"; series.values = Array.from({ length: 300 }, (_, index) => ({ timestamp: Date.UTC(2026, 0, 1) + index * series.meta.interval, @@ -585,7 +583,7 @@ describe("Explore time-series graphics", () => { "preserves JSON with fields %j without probing the terminal", (fields) => { const data = makeData(); - data.timeSeries[0]!.values[1]!.value = null; + data.timeSeries[0].values[1].value = null; const original = structuredClone(data); const chunks: (string | Uint8Array)[] = []; const config = { diff --git a/packages/cli/test/lib/formatters/human.property.test.ts b/packages/cli/test/lib/formatters/human.property.test.ts index 0ad70e5f9..b0ba2070b 100644 --- a/packages/cli/test/lib/formatters/human.property.test.ts +++ b/packages/cli/test/lib/formatters/human.property.test.ts @@ -250,11 +250,7 @@ describe("formatUserIdentity properties", () => { const scoreArb = double({ min: 0, max: 1, noNaN: true }); /** Score or null/undefined (full input space for formatFixability) */ -const nullableScoreArb = oneof( - scoreArb, - constant(null as null), - constant(undefined as undefined), -); +const nullableScoreArb = oneof(scoreArb, constant(null), constant(undefined)); describe("property: getSeerFixabilityLabel", () => { test("always returns one of the three valid tiers", () => { @@ -272,10 +268,8 @@ describe("property: getSeerFixabilityLabel", () => { fcAssert( property(scoreArb, scoreArb, (a, b) => { if (a <= b) { - const rankA = - tierRank[getSeerFixabilityLabel(a) as keyof typeof tierRank]; - const rankB = - tierRank[getSeerFixabilityLabel(b) as keyof typeof tierRank]; + const rankA = tierRank[getSeerFixabilityLabel(a)]; + const rankB = tierRank[getSeerFixabilityLabel(b)]; expect(rankA).toBeLessThanOrEqual(rankB); } }), diff --git a/packages/cli/test/lib/formatters/human.test.ts b/packages/cli/test/lib/formatters/human.test.ts index 4ced119b4..25f0ceb70 100644 --- a/packages/cli/test/lib/formatters/human.test.ts +++ b/packages/cli/test/lib/formatters/human.test.ts @@ -398,8 +398,8 @@ describe("writeIssueTable", () => { { issue: { ...mockIssue, - lastSeen: null as unknown as string, - firstSeen: null as unknown as string, + lastSeen: null, + firstSeen: null, }, orgSlug: "test-org", formatOptions: { projectSlug: "dashboard" }, @@ -613,7 +613,7 @@ describe("formatProjectCreated", () => { name: "My Project", slug: "my-project", platform: "javascript", - } as ProjectCreatedResult["project"], + }, orgSlug: "my-org", teamSlug: "my-team", teamSource: "explicit", @@ -650,7 +650,7 @@ describe("formatProjectCreated", () => { project: { ...baseResult.project, slug: "my-project-1", - } as ProjectCreatedResult["project"], + }, expectedSlug: "my-project", }), ); @@ -681,7 +681,7 @@ describe("formatProjectCreated", () => { project: { ...baseResult.project, platform: "", - } as ProjectCreatedResult["project"], + }, }), ); expect(result).toContain("javascript"); diff --git a/packages/cli/test/lib/formatters/issue-tags.test.ts b/packages/cli/test/lib/formatters/issue-tags.test.ts index f6891b255..e611188e5 100644 --- a/packages/cli/test/lib/formatters/issue-tags.test.ts +++ b/packages/cli/test/lib/formatters/issue-tags.test.ts @@ -43,7 +43,7 @@ describe("formatIssueTags", () => { test("distinguishes empty values from unknown values and preserves literal tag text", () => { const tag = distribution(); - const value = tag.topValues![0]!; + const value = tag.topValues![0]; tag.topValues = [ { ...value, value: "" }, { ...value, value: null }, diff --git a/packages/cli/test/lib/formatters/local.property.test.ts b/packages/cli/test/lib/formatters/local.property.test.ts index 7d37f7f45..9b72e4755 100644 --- a/packages/cli/test/lib/formatters/local.property.test.ts +++ b/packages/cli/test/lib/formatters/local.property.test.ts @@ -122,9 +122,7 @@ describe("property: isItemIncluded", () => { fcAssert( property(itemTypes, (itemType) => { const empty = new Set(); - expect(isItemIncluded(itemType as string | undefined, empty)).toBe( - true, - ); + expect(isItemIncluded(itemType, empty)).toBe(true); }), { numRuns: DEFAULT_NUM_RUNS }, ); diff --git a/packages/cli/test/lib/formatters/local.test.ts b/packages/cli/test/lib/formatters/local.test.ts index 95a6c3ea8..81d0954fd 100644 --- a/packages/cli/test/lib/formatters/local.test.ts +++ b/packages/cli/test/lib/formatters/local.test.ts @@ -1159,8 +1159,8 @@ describe("standalone span support", () => { const payload = { items: [aiSpan, mcpSpan] }; const lines = formatSpanItem(payload, cfHeader); expect(lines).toHaveLength(2); - expect(stripAnsi(lines[0]!)).toContain("gen_ai"); - expect(stripAnsi(lines[1]!)).toContain("mcp"); + expect(stripAnsi(lines[0])).toContain("gen_ai"); + expect(stripAnsi(lines[1])).toContain("mcp"); }); test("returns empty for missing items", () => { @@ -1174,7 +1174,7 @@ describe("standalone span support", () => { const payload = { items: [aiSpan] }; const lines = formatItem("span", payload, cfHeader, "span"); expect(lines.length).toBeGreaterThanOrEqual(1); - expect(stripAnsi(lines[0]!)).toContain("gen_ai"); + expect(stripAnsi(lines[0])).toContain("gen_ai"); }); }); @@ -1183,7 +1183,7 @@ describe("standalone span support", () => { const payload = { items: [aiSpan] }; const lines = formatItemJson("span", payload, cfHeader); expect(lines).toHaveLength(1); - const parsed = JSON.parse(lines[0]!); + const parsed = JSON.parse(lines[0]); expect(parsed.type).toBe("span"); expect(parsed.trace_id).toBe("a".repeat(32)); expect(parsed.span_id).toBe("b".repeat(16)); diff --git a/packages/cli/test/lib/formatters/log.test.ts b/packages/cli/test/lib/formatters/log.test.ts index 9c025808b..8a2d760ac 100644 --- a/packages/cli/test/lib/formatters/log.test.ts +++ b/packages/cli/test/lib/formatters/log.test.ts @@ -553,7 +553,7 @@ describe("formatLogDetails", () => { test("fallback: shows extraFields from log when allAttributes absent", () => { const log = createDetailedTestLog({ "user.id": "u_99", - } as DetailedSentryLog); + }); const result = stripAnsi( formatLogDetails(log, "test-org", undefined, ["user.id"]), ); @@ -566,7 +566,7 @@ describe("formatLogDetails", () => { test("fallback: shows Markdown in extraFields names and values literally", () => { const log = createDetailedTestLog({ "a|b": "**bold** [link](https://example.com)", - } as DetailedSentryLog); + }); const result = stripAnsi( formatLogDetails(log, "test-org", undefined, ["a|b"]), ); diff --git a/packages/cli/test/lib/formatters/table.test.ts b/packages/cli/test/lib/formatters/table.test.ts index fff9bb872..0948640ad 100644 --- a/packages/cli/test/lib/formatters/table.test.ts +++ b/packages/cli/test/lib/formatters/table.test.ts @@ -114,7 +114,7 @@ describe("writeTable (TTY mode)", () => { } else { delete process.env.SENTRY_PLAIN_OUTPUT; } - process.stdout.columns = saved.columns as number; + process.stdout.columns = saved.columns; } } diff --git a/packages/cli/test/lib/formatters/trace.property.test.ts b/packages/cli/test/lib/formatters/trace.property.test.ts index 6cd773908..043a5a2c0 100644 --- a/packages/cli/test/lib/formatters/trace.property.test.ts +++ b/packages/cli/test/lib/formatters/trace.property.test.ts @@ -98,7 +98,7 @@ function makeSpanArb(): import("fast-check").Arbitrary { constantFrom("http.server", "browser", "celery_task"), { nil: undefined }, ), - }) as unknown as import("fast-check").Arbitrary; + }); } /** Generate a list of flat TraceSpans (1-10) */ diff --git a/packages/cli/test/lib/ghcr.test.ts b/packages/cli/test/lib/ghcr.test.ts index bdba5f524..d1bfa9d8f 100644 --- a/packages/cli/test/lib/ghcr.test.ts +++ b/packages/cli/test/lib/ghcr.test.ts @@ -31,7 +31,7 @@ let originalFetch: typeof globalThis.fetch; function mockFetch( fn: (url: string | URL | Request, init?: RequestInit) => Promise, ): void { - globalThis.fetch = fn as typeof globalThis.fetch; + globalThis.fetch = fn; } /** Minimal valid OCI manifest for testing */ diff --git a/packages/cli/test/lib/git-commit-log.test.ts b/packages/cli/test/lib/git-commit-log.test.ts index 9408d5069..19ba8699a 100644 --- a/packages/cli/test/lib/git-commit-log.test.ts +++ b/packages/cli/test/lib/git-commit-log.test.ts @@ -12,7 +12,7 @@ import { getCommitLog } from "../../src/lib/git.js"; function lastGitArgs(): string[] { const call = execFileSyncMock.mock.calls.at(-1); // execFileSync(file, args, options) - return (call?.[1] ?? []) as string[]; + return call?.[1] ?? []; } describe("getCommitLog pathspec argv", () => { diff --git a/packages/cli/test/lib/hex-id-recovery.adapters.test.ts b/packages/cli/test/lib/hex-id-recovery.adapters.test.ts index 694a58c9f..61652fec5 100644 --- a/packages/cli/test/lib/hex-id-recovery.adapters.test.ts +++ b/packages/cli/test/lib/hex-id-recovery.adapters.test.ts @@ -97,7 +97,7 @@ describe("adapter query params", () => { test("event adapter queries the errors dataset with project scope", async () => { let queryUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); queryUrl = req.url; return eventsResponse([ { @@ -130,7 +130,7 @@ describe("adapter query params", () => { test("trace adapter queries the spans dataset and extracts trace field", async () => { let queryUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); queryUrl = req.url; return eventsResponse([ { @@ -165,7 +165,7 @@ describe("adapter query params", () => { let queryUrl = ""; const traceId = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); queryUrl = req.url; return eventsResponse([ { @@ -191,7 +191,7 @@ describe("adapter query params", () => { test("log adapter queries the logs dataset and extracts sentry.item_id", async () => { let queryUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); queryUrl = req.url; return new Response( JSON.stringify({ @@ -238,7 +238,7 @@ describe("adapter query params", () => { test("ctx.period override replaces the default scan window", async () => { let queryUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); queryUrl = req.url; return eventsResponse([]); }); @@ -264,7 +264,7 @@ describe("recoverHexId trace redirect via findTraceBySpanId", () => { const parentTrace = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; let queryUrl = ""; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input!, init); + const req = new Request(input, init); queryUrl = req.url; return eventsResponse([ { diff --git a/packages/cli/test/lib/id-arguments.test.ts b/packages/cli/test/lib/id-arguments.test.ts index 75470514b..346886942 100644 --- a/packages/cli/test/lib/id-arguments.test.ts +++ b/packages/cli/test/lib/id-arguments.test.ts @@ -35,7 +35,7 @@ const EXAMPLES: Record = { }; const KINDS = (Object.keys(EXAMPLES) as UnnamedKind[]).map( - (name) => [name, ID_KINDS[name] as IdKind, ...EXAMPLES[name]] as const, + (name) => [name, ID_KINDS[name], ...EXAMPLES[name]] as const, ); function parse( diff --git a/packages/cli/test/lib/install-ps1-script.test.ts b/packages/cli/test/lib/install-ps1-script.test.ts index fd6acecd5..b760cf8ef 100644 --- a/packages/cli/test/lib/install-ps1-script.test.ts +++ b/packages/cli/test/lib/install-ps1-script.test.ts @@ -214,7 +214,7 @@ describe.skipIf(!hasPwsh)("PowerShell install script", () => { expect(recorded("post-args")).toEqual(["init"]); const [initBinary] = recorded("post-binary"); expect(initBinary?.startsWith(join(testDir, "sentry-install-"))).toBe(true); - expect(existsSync(initBinary!)).toBe(false); + expect(existsSync(initBinary)).toBe(false); }); test("fails when sentry init fails", () => { diff --git a/packages/cli/test/lib/mcp/process-handlers.test.ts b/packages/cli/test/lib/mcp/process-handlers.test.ts index 149d69cb0..016cfd6c0 100644 --- a/packages/cli/test/lib/mcp/process-handlers.test.ts +++ b/packages/cli/test/lib/mcp/process-handlers.test.ts @@ -91,22 +91,19 @@ describe("installProcessHandlers", () => { // The code each exit would end the process with: its argument, or // `process.exitCode` when it has none. const codes: unknown[] = []; - exit.mockImplementation(((code?: number) => { + exit.mockImplementation((code?: number) => { codes.push(code ?? process.exitCode ?? 0); - }) as typeof process.exit); + }); let stderrError: Handler | undefined; - vi.spyOn(process.stderr, "on").mockImplementation((( - event: string, - handler: Handler, - ) => { - if (event === "error") { - stderrError = handler; - } - return process.stderr; - }) as typeof process.stderr.on); - vi.spyOn(process.stdout, "on").mockImplementation( - (() => process.stdout) as typeof process.stdout.on, + vi.spyOn(process.stderr, "on").mockImplementation( + (event: string, handler: Handler) => { + if (event === "error") { + stderrError = handler; + } + return process.stderr; + }, ); + vi.spyOn(process.stdout, "on").mockImplementation(() => process.stdout); installStreamErrorHandlers(); const exitAfterError = installProcessHandlers(); // The client closed its pipes: writing the report raises EPIPE. diff --git a/packages/cli/test/lib/mcp/telemetry.test.ts b/packages/cli/test/lib/mcp/telemetry.test.ts index 9029bd6ea..7cd3f3afd 100644 --- a/packages/cli/test/lib/mcp/telemetry.test.ts +++ b/packages/cli/test/lib/mcp/telemetry.test.ts @@ -98,7 +98,7 @@ function buildTransport(options: NodeOptions, url: string) { if (!options.transport) { throw new Error("Sentry.init got no transport"); } - return options.transport({ url, recordDroppedEvent: noop } as never); + return options.transport({ url, recordDroppedEvent: noop }); } describe("initMcpTelemetry", () => { diff --git a/packages/cli/test/lib/oauth.test.ts b/packages/cli/test/lib/oauth.test.ts index 07adc86de..f2c83a076 100644 --- a/packages/cli/test/lib/oauth.test.ts +++ b/packages/cli/test/lib/oauth.test.ts @@ -231,7 +231,7 @@ describe("setup-code exchange", () => { await exchangeSetupCode("private-code", "https://sentry.example.com"), ).toEqual(token); expect(fetch).toHaveBeenCalledTimes(1); - const [url, init] = fetch.mock.calls[0]!; + const [url, init] = fetch.mock.calls[0]; expect(url).toBe("https://sentry.example.com/oauth/token/"); expect(init.redirect).toBe("error"); expect(init.body.get("grant_type")).toBe( diff --git a/packages/cli/test/lib/org-list.test.ts b/packages/cli/test/lib/org-list.test.ts index 2e7be4889..12c75709e 100644 --- a/packages/cli/test/lib/org-list.test.ts +++ b/packages/cli/test/lib/org-list.test.ts @@ -243,8 +243,8 @@ describe("fetchAllOrgs", () => { const result = await fetchAllOrgs(config); expect(result).toHaveLength(2); - expect(result[0]!.orgSlug).toBe("org-a"); - expect(result[1]!.orgSlug).toBe("org-b"); + expect(result[0].orgSlug).toBe("org-a"); + expect(result[1].orgSlug).toBe("org-b"); }); test("skips orgs with non-auth errors", async () => { @@ -264,7 +264,7 @@ describe("fetchAllOrgs", () => { const result = await fetchAllOrgs(config); expect(result).toHaveLength(1); - expect(result[0]!.orgSlug).toBe("org-b"); + expect(result[0].orgSlug).toBe("org-b"); }); test("rethrows AuthError from any org", async () => { @@ -323,7 +323,7 @@ describe("handleOrgAll", () => { // paginate() wraps the server cursor with the walk's page size. expect(result.nextCursor).toContain("next:123"); expect(result.items).toHaveLength(1); - expect(result.items[0]!.orgSlug).toBe("my-org"); + expect(result.items[0].orgSlug).toBe("my-org"); }); test("caps perPage at API_MAX_PER_PAGE when limit exceeds it", async () => { @@ -565,7 +565,7 @@ describe("handleExplicitOrg", () => { }); expect(result.items).toHaveLength(1); - expect(result.items[0]!.orgSlug).toBe("my-org"); + expect(result.items[0].orgSlug).toBe("my-org"); }); test("includes org-scoped note in header when noteOrgScoped=true", async () => { @@ -636,7 +636,7 @@ describe("handleExplicitProject", () => { expect(listForProject).toHaveBeenCalledWith("my-org", "my-proj"); expect(result.items).toHaveLength(1); - expect(result.items[0]!.orgSlug).toBe("my-org"); + expect(result.items[0].orgSlug).toBe("my-org"); }); test("throws when listForProject is not defined on config", async () => { @@ -724,7 +724,7 @@ describe("handleProjectSearch", () => { }); expect(listForProject).toHaveBeenCalledWith("org-a", "my-proj"); - expect(result.items[0]!.orgSlug).toBe("org-a"); + expect(result.items[0].orgSlug).toBe("org-a"); }); test("reuses fuzzy project data without a second slug search", async () => { @@ -770,7 +770,7 @@ describe("handleProjectSearch", () => { }); expect(listForOrg).toHaveBeenCalledWith("org-a"); - expect(result.items[0]!.orgSlug).toBe("org-a"); + expect(result.items[0].orgSlug).toBe("org-a"); }); test("deduplicates orgs when multiple projects share one org", async () => { diff --git a/packages/cli/test/lib/proguard.property.test.ts b/packages/cli/test/lib/proguard.property.test.ts index 94ceaef86..8d994ea19 100644 --- a/packages/cli/test/lib/proguard.property.test.ts +++ b/packages/cli/test/lib/proguard.property.test.ts @@ -72,7 +72,7 @@ describe("proguard: computeProguardUuid", () => { const original = Buffer.from(bytes); const mutated = Buffer.from(bytes); // Flip the first byte to guarantee different content. - mutated[0] = (mutated[0]! + 1) % 256; + mutated[0] = (mutated[0] + 1) % 256; expect(computeProguardUuid(original)).not.toBe( computeProguardUuid(mutated), ); diff --git a/packages/cli/test/lib/release-notes.test.ts b/packages/cli/test/lib/release-notes.test.ts index bd2445fa6..fc41b9f40 100644 --- a/packages/cli/test/lib/release-notes.test.ts +++ b/packages/cli/test/lib/release-notes.test.ts @@ -109,7 +109,7 @@ describe("extractSections", () => { "### Performance\n\n- Optimize query execution\n- Reduce memory usage"; const sections = extractSections(body); expect(sections).toHaveLength(1); - expect(sections[0]!.category).toBe("performance"); + expect(sections[0].category).toBe("performance"); }); }); @@ -229,7 +229,7 @@ describe("parseCommitMessages", () => { ]; const sections = parseCommitMessages(commits); - expect(sections[0]!.markdown).toContain("add pagination support"); + expect(sections[0].markdown).toContain("add pagination support"); }); test("uses only first line of multi-line messages", () => { @@ -243,8 +243,8 @@ describe("parseCommitMessages", () => { ]; const sections = parseCommitMessages(commits); - expect(sections[0]!.markdown).toContain("short summary"); - expect(sections[0]!.markdown).not.toContain("Long description"); + expect(sections[0].markdown).toContain("short summary"); + expect(sections[0].markdown).not.toContain("Long description"); }); test("filters #skip-changelog commits", () => { @@ -302,8 +302,8 @@ describe("countListItems", () => { }); describe("fetchChangelog source affinity", () => { - const toolkitSource = UPGRADE_SOURCES[0]!; - const legacySource = UPGRADE_SOURCES[1]!; + const toolkitSource = UPGRADE_SOURCES[0]; + const legacySource = UPGRADE_SOURCES[1]; let originalFetch: typeof globalThis.fetch; beforeEach(() => { diff --git a/packages/cli/test/lib/resolve-target.test.ts b/packages/cli/test/lib/resolve-target.test.ts index 3856547cb..6956bf041 100644 --- a/packages/cli/test/lib/resolve-target.test.ts +++ b/packages/cli/test/lib/resolve-target.test.ts @@ -906,7 +906,7 @@ describe("tryFuzzyProjectRecovery", () => { // Match /organizations//projects/ const orgMatch = url.match(/\/organizations\/([^/]+)\/projects/); if (orgMatch) { - const org = orgMatch[1] as string; + const org = orgMatch[1]; const slugs = projectsByOrg[org]; if (slugs) { const projects = slugs.map((slug, i) => ({ diff --git a/packages/cli/test/lib/response-cache-store.test.ts b/packages/cli/test/lib/response-cache-store.test.ts index 814261095..0a7d428fb 100644 --- a/packages/cli/test/lib/response-cache-store.test.ts +++ b/packages/cli/test/lib/response-cache-store.test.ts @@ -58,7 +58,7 @@ async function lastUsed(key: string, secondsAgo: number): Promise { } async function keys(): Promise { - return (await readdir(dir)).map((file) => file.split(".")[0]!).sort(); + return (await readdir(dir)).map((file) => file.split(".")[0]).sort(); } describe("createFileStore", () => { diff --git a/packages/cli/test/lib/response-cache.test.ts b/packages/cli/test/lib/response-cache.test.ts index d5ab53a65..71cf686df 100644 --- a/packages/cli/test/lib/response-cache.test.ts +++ b/packages/cli/test/lib/response-cache.test.ts @@ -680,7 +680,7 @@ describe("entry format", () => { ); const [file] = await readdir(cacheDir()); - const raw = await readFile(join(cacheDir(), file!), "utf-8"); + const raw = await readFile(join(cacheDir(), file), "utf-8"); const stored = JSON.parse(raw) as { body: { encoding: string } }; expect(["zstd", "br"]).toContain(stored.body.encoding); expect(raw.length).toBeLessThan(text.length); diff --git a/packages/cli/test/lib/scan/grep.property.test.ts b/packages/cli/test/lib/scan/grep.property.test.ts index 744fa280f..b82371871 100644 --- a/packages/cli/test/lib/scan/grep.property.test.ts +++ b/packages/cli/test/lib/scan/grep.property.test.ts @@ -81,7 +81,7 @@ function naiveGrep( for (const [path, content] of layout) { const lines = content.split("\n"); for (let i = 0; i < lines.length; i += 1) { - const line = lines[i] as string; + const line = lines[i]; if (regex.test(line)) { out.push({ path, lineNum: i + 1, line }); } diff --git a/packages/cli/test/lib/security/custom-headers-leak.test.ts b/packages/cli/test/lib/security/custom-headers-leak.test.ts index 37aa6ec1b..885e038cf 100644 --- a/packages/cli/test/lib/security/custom-headers-leak.test.ts +++ b/packages/cli/test/lib/security/custom-headers-leak.test.ts @@ -54,15 +54,12 @@ describe("CVE: custom-headers leak (share URL + auth-login bypass)", () => { // Intercept fetch to capture outbound headers const originalFetch = globalThis.fetch; let capturedHeaders: Headers | undefined; - globalThis.fetch = (async ( - input: RequestInfo | URL, - init?: RequestInit, - ) => { + globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit) => { capturedHeaders = new Headers( init?.headers ?? (input instanceof Request ? input.headers : undefined), ); return new Response("{}", { status: 404 }); - }) as typeof fetch; + }; try { await getSharedIssue( diff --git a/packages/cli/test/lib/security/login-token-rc-poison.test.ts b/packages/cli/test/lib/security/login-token-rc-poison.test.ts index 325427ff8..96d43e00b 100644 --- a/packages/cli/test/lib/security/login-token-rc-poison.test.ts +++ b/packages/cli/test/lib/security/login-token-rc-poison.test.ts @@ -93,10 +93,7 @@ describe("CVE: auth login --token with rc-poisoned env.SENTRY_URL", () => { // Intercept fetch to assert no outbound requests on the attacker path. fetchCalls = []; originalFetch = globalThis.fetch; - globalThis.fetch = (async ( - input: RequestInfo | URL, - init?: RequestInit, - ) => { + globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit) => { const headers = new Headers( init?.headers ?? (input instanceof Request ? input.headers : undefined), ); @@ -105,7 +102,7 @@ describe("CVE: auth login --token with rc-poisoned env.SENTRY_URL", () => { authorization: headers.get("Authorization"), }); throw new Error("test: unexpected fetch"); - }) as typeof fetch; + }; }); afterEach(async () => { diff --git a/packages/cli/test/lib/security/refresh-token-poison.test.ts b/packages/cli/test/lib/security/refresh-token-poison.test.ts index 2c03b2e77..0c62fe1c0 100644 --- a/packages/cli/test/lib/security/refresh-token-poison.test.ts +++ b/packages/cli/test/lib/security/refresh-token-poison.test.ts @@ -34,10 +34,10 @@ describe("CVE defense-in-depth: refresh token", () => { // Intercept fetch to detect any outbound request attempt. fetchCalls = []; originalFetch = globalThis.fetch; - globalThis.fetch = (async (input: RequestInfo | URL) => { + globalThis.fetch = async (input: RequestInfo | URL) => { fetchCalls.push(extractFetchUrl(input)); throw new Error("test: unexpected fetch"); - }) as typeof fetch; + }; }); afterEach(() => { @@ -101,10 +101,10 @@ describe("CVE defense-in-depth: refresh token", () => { delete process.env.SENTRY_HOST; delete process.env.SENTRY_URL; const credentialHost = "https://sentry.example.com:8443"; - globalThis.fetch = (async (input: RequestInfo | URL) => { + globalThis.fetch = async (input: RequestInfo | URL) => { fetchCalls.push(extractFetchUrl(input)); throw failure; - }) as typeof fetch; + }; await expect( refreshAccessToken("fake-refresh-token", { credentialHost }), diff --git a/packages/cli/test/lib/security/sntrys-claim-mismatch.test.ts b/packages/cli/test/lib/security/sntrys-claim-mismatch.test.ts index 50d76f63c..f6d2a097f 100644 --- a/packages/cli/test/lib/security/sntrys-claim-mismatch.test.ts +++ b/packages/cli/test/lib/security/sntrys-claim-mismatch.test.ts @@ -48,10 +48,7 @@ describe("CVE defense-in-depth: sntrys_ claim vs request mismatch", () => { fetchCalls = []; originalFetch = globalThis.fetch; - globalThis.fetch = (async ( - input: RequestInfo | URL, - init?: RequestInit, - ) => { + globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit) => { const headers = new Headers( init?.headers ?? (input instanceof Request ? input.headers : undefined), ); @@ -60,7 +57,7 @@ describe("CVE defense-in-depth: sntrys_ claim vs request mismatch", () => { auth: headers.get("Authorization"), }); return new Response("{}", { status: 200 }); - }) as typeof fetch; + }; }); afterEach(async () => { diff --git a/packages/cli/test/lib/sentry-client.invalidation.test.ts b/packages/cli/test/lib/sentry-client.invalidation.test.ts index 9b5c4d224..002cab134 100644 --- a/packages/cli/test/lib/sentry-client.invalidation.test.ts +++ b/packages/cli/test/lib/sentry-client.invalidation.test.ts @@ -49,8 +49,8 @@ afterEach(() => { /** Swap `globalThis.fetch` with a deterministic handler for one test. */ function installMockFetch(handler: FetchHandler): void { - globalThis.fetch = ((input: Request | string | URL, init?: RequestInit) => - handler(input, init)) as typeof fetch; + globalThis.fetch = (input: Request | string | URL, init?: RequestInit) => + handler(input, init); } /** diff --git a/packages/cli/test/lib/sentry-client.revalidation.test.ts b/packages/cli/test/lib/sentry-client.revalidation.test.ts index dba4bd104..1966748c4 100644 --- a/packages/cli/test/lib/sentry-client.revalidation.test.ts +++ b/packages/cli/test/lib/sentry-client.revalidation.test.ts @@ -49,7 +49,7 @@ function json(body: unknown, headers: Record = {}): Response { /** Serve `replies` in order, recording each request's `If-None-Match`. */ function mockApi(...replies: Response[]): Seen[] { const seen: Seen[] = []; - globalThis.fetch = (async ( + globalThis.fetch = async ( input: Request | string | URL, init?: RequestInit, ) => { @@ -62,7 +62,7 @@ function mockApi(...replies: Response[]): Seen[] { throw new Error("Unexpected request"); } return reply; - }) as typeof fetch; + }; return seen; } diff --git a/packages/cli/test/lib/sentry-client.test.ts b/packages/cli/test/lib/sentry-client.test.ts index e1506bb40..45f186fa8 100644 --- a/packages/cli/test/lib/sentry-client.test.ts +++ b/packages/cli/test/lib/sentry-client.test.ts @@ -39,12 +39,12 @@ afterEach(() => { }); function getAuthenticatedFetch(): typeof fetch { - return getSdkConfig(REGION_URL).fetch as typeof fetch; + return getSdkConfig(REGION_URL).fetch; } /** Fetch for callers that opted in to replaying writes (chunk uploads). */ function getIdempotentFetch(): typeof fetch { - return getSdkConfig(REGION_URL, { idempotent: true }).fetch as typeof fetch; + return getSdkConfig(REGION_URL, { idempotent: true }).fetch; } function jsonResponse( @@ -149,7 +149,7 @@ describe("fetchWithRetry / buildAttemptFactory", () => { callCount += 1; const body = init?.body; if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) { - seen.push(new TextDecoder().decode(body as ArrayBuffer)); + seen.push(new TextDecoder().decode(body)); } else if (typeof body === "string") { seen.push(body); } else if (body) { @@ -201,7 +201,7 @@ describe("fetchWithRetry / buildAttemptFactory", () => { globalThis.fetch = mockFetch(async (input, init) => { callCount += 1; - const req = new Request(input as string, init); + const req = new Request(input, init); contentTypes.push(req.headers.get("content-type")); bodies.push(await req.text()); if (callCount === 1) { @@ -355,7 +355,7 @@ describe("non-idempotent requests", () => { setAuthToken("initial-token", 3600, "test-refresh-token"); const seen: { auth: string | null; body: string }[] = []; globalThis.fetch = mockFetch(async (input, init) => { - const req = new Request(input as Request, init); + const req = new Request(input, init); if (req.url.includes("/oauth/token/")) { return jsonResponse({ access_token: "refreshed-token", @@ -503,7 +503,7 @@ describe("429 rate limiting", () => { test("retries a POST on 429, since the request was rejected before processing", async () => { const bodies: string[] = []; globalThis.fetch = mockFetch(async (input, init) => { - bodies.push(await new Request(input as string, init).text()); + bodies.push(await new Request(input, init).text()); return bodies.length === 1 ? jsonResponse( { detail: "slow down" }, diff --git a/packages/cli/test/lib/sixel-image.test.ts b/packages/cli/test/lib/sixel-image.test.ts index 6a2e69774..e107f769a 100644 --- a/packages/cli/test/lib/sixel-image.test.ts +++ b/packages/cli/test/lib/sixel-image.test.ts @@ -218,7 +218,7 @@ describe("buildPalette", () => { const width = 30; const data = new Uint8Array(width * 4); for (let x = 0; x < width; x++) { - const [r, g, b] = colors[x % colors.length] as [number, number, number]; + const [r, g, b] = colors[x % colors.length]; data.set([r, g, b, 255], x * 4); } expect(buildPalette({ width, height: 1, data }, 16)).toEqual(colors); diff --git a/packages/cli/test/lib/telemetry/offline-store.test.ts b/packages/cli/test/lib/telemetry/offline-store.test.ts index 3652abb9d..ca181a15f 100644 --- a/packages/cli/test/lib/telemetry/offline-store.test.ts +++ b/packages/cli/test/lib/telemetry/offline-store.test.ts @@ -191,7 +191,7 @@ describe.each(["node", "wasm"] as const)( await store.push(transactionEnvelope("a")); clock.now += 3 * DAY_MS; const [claimed] = store.claim(1); - await store.push(claimed as Envelope); + await store.push(claimed); clock.now += 2 * DAY_MS; expect(store.claim(10)).toEqual([]); diff --git a/packages/cli/test/lib/telemetry/offline-transport.e2e.test.ts b/packages/cli/test/lib/telemetry/offline-transport.e2e.test.ts index 2e8f38f6f..1949c37e9 100644 --- a/packages/cli/test/lib/telemetry/offline-transport.e2e.test.ts +++ b/packages/cli/test/lib/telemetry/offline-transport.e2e.test.ts @@ -52,8 +52,7 @@ function storedEventIds(): string[] { /** Event IDs in the bodies a mock ingest received (bodies are small, so uncompressed). */ function deliveredEventIds(captures: { body: Buffer }[]): string[] { return captures.map( - (capture) => - JSON.parse(capture.body.toString().split("\n")[0] as string).event_id, + (capture) => JSON.parse(capture.body.toString().split("\n")[0]).event_id, ); } @@ -120,7 +119,7 @@ describe("makeStoringTransport (e2e)", () => { expect(deliveredEventIds(ingest.captures).sort()).toEqual(["a", "b"]); expect(storedEventIds()).toEqual([]); const header = JSON.parse( - ingest.captures[0]?.body.toString().split("\n")[0] as string, + ingest.captures[0]?.body.toString().split("\n")[0], ); expect(Date.parse(header.sent_at)).toBeGreaterThan(Date.now() - 60_000); }); diff --git a/packages/cli/test/lib/telemetry/zstd-transport.e2e.test.ts b/packages/cli/test/lib/telemetry/zstd-transport.e2e.test.ts index 70e1ed37e..9c0a4f4fe 100644 --- a/packages/cli/test/lib/telemetry/zstd-transport.e2e.test.ts +++ b/packages/cli/test/lib/telemetry/zstd-transport.e2e.test.ts @@ -53,7 +53,7 @@ describe("makeCompressedTransport (e2e)", () => { expect(captures).toHaveLength(1); expect(captures[0]?.headers["content-encoding"]).toBe("zstd"); - const decompressed = await promisify(zstdDecompress)(captures[0]!.body); + const decompressed = await promisify(zstdDecompress)(captures[0].body); const text = Buffer.from( decompressed.buffer, decompressed.byteOffset, diff --git a/packages/cli/test/lib/telemetry/zstd-transport.test.ts b/packages/cli/test/lib/telemetry/zstd-transport.test.ts index bf1499486..15f83fe16 100644 --- a/packages/cli/test/lib/telemetry/zstd-transport.test.ts +++ b/packages/cli/test/lib/telemetry/zstd-transport.test.ts @@ -100,7 +100,7 @@ function buildMockHttpModule(response: MockResponseShape): { return req; }, }; - return { httpModule: httpModule as never, captured }; + return { httpModule: httpModule, captured }; } // ── Tests ──────────────────────────────────────────────────────────── @@ -300,7 +300,7 @@ describe("makeCompressedTransport", () => { }; const transport = makeCompressedTransport({ ...BASE_OPTIONS, - httpModule: throwingMod as never, + httpModule: throwingMod, }); const envelope: any = createEnvelope({} as any, [ [{ type: "event" } as any, { data: "x".repeat(4096) } as any], diff --git a/packages/cli/test/lib/time-range.property.test.ts b/packages/cli/test/lib/time-range.property.test.ts index 14476e27e..0beca3a12 100644 --- a/packages/cli/test/lib/time-range.property.test.ts +++ b/packages/cli/test/lib/time-range.property.test.ts @@ -44,7 +44,7 @@ const sortedDatePairArb = array(isoDateArb, { minLength: 2, maxLength: 2 }).map( const sorted = [...dates].sort(); // Ensure they're different (no zero-length range issues) if (sorted[0] === sorted[1]) { - const d = new Date(sorted[1]!); + const d = new Date(sorted[1]); d.setDate(d.getDate() + 1); sorted[1] = d.toISOString().slice(0, 10); } diff --git a/packages/cli/test/lib/trials.test.ts b/packages/cli/test/lib/trials.test.ts index 8a7c74e0f..35f149884 100644 --- a/packages/cli/test/lib/trials.test.ts +++ b/packages/cli/test/lib/trials.test.ts @@ -235,13 +235,13 @@ describe("getTrialStatus", () => { const trial = makeTrial({ isStarted: true, startDate: "2025-01-01", - endDate: tomorrow.toISOString().split("T")[0]!, + endDate: tomorrow.toISOString().split("T")[0], }); expect(getTrialStatus(trial)).toBe("active"); }); test("returns 'active' when started with today as end date", () => { - const today = new Date().toISOString().split("T")[0]!; + const today = new Date().toISOString().split("T")[0]; const trial = makeTrial({ isStarted: true, startDate: "2025-01-01", @@ -292,7 +292,7 @@ describe("getDaysRemaining", () => { future.setDate(future.getDate() + 10); const trial = makeTrial({ isStarted: true, - endDate: future.toISOString().split("T")[0]!, + endDate: future.toISOString().split("T")[0], }); const days = getDaysRemaining(trial); expect(days).not.toBeNull(); diff --git a/packages/cli/test/lib/upgrade.test.ts b/packages/cli/test/lib/upgrade.test.ts index e9144caf0..f6c2bc828 100644 --- a/packages/cli/test/lib/upgrade.test.ts +++ b/packages/cli/test/lib/upgrade.test.ts @@ -156,7 +156,7 @@ let originalFetch: typeof globalThis.fetch; function mockFetch( fn: (url: string | URL | Request, init?: RequestInit) => Promise, ): void { - globalThis.fetch = fn as typeof globalThis.fetch; + globalThis.fetch = fn; } beforeEach(() => { @@ -2752,7 +2752,7 @@ describe("executeUpgrade (package managers)", () => { describe("executeUpgrade (unknown method)", () => { test("throws UpgradeError with unknown_method reason", async () => { try { - await executeUpgrade("unknown" as never, "1.0.0"); + await executeUpgrade("unknown", "1.0.0"); expect.unreachable("should have thrown"); } catch (err) { expect(err).toBeInstanceOf(UpgradeError); diff --git a/packages/cli/test/lib/version-check.test.ts b/packages/cli/test/lib/version-check.test.ts index 60ab208e2..23eb681a0 100644 --- a/packages/cli/test/lib/version-check.test.ts +++ b/packages/cli/test/lib/version-check.test.ts @@ -654,7 +654,7 @@ describe("maybeCheckForUpdateInBackground", () => { }); test("passes the Toolkit source from stable discovery to patch prefetch without legacy access", async () => { - const toolkitSource = UPGRADE_SOURCES[0]!; + const toolkitSource = UPGRADE_SOURCES[0]; const requestedUrls: string[] = []; globalThis.fetch = mockFetch(async (input) => { const url = extractInputUrl(input); @@ -686,7 +686,7 @@ describe("maybeCheckForUpdateInBackground", () => { }); test("keeps stable patch prefetch on the legacy source selected after a Toolkit 404", async () => { - const legacySource = UPGRADE_SOURCES[1]!; + const legacySource = UPGRADE_SOURCES[1]; const requestedUrls: string[] = []; globalThis.fetch = mockFetch(async (input) => { const url = extractInputUrl(input); @@ -724,7 +724,7 @@ describe("maybeCheckForUpdateInBackground", () => { test("passes the Toolkit source from nightly discovery to patch prefetch without legacy access", async () => { setReleaseChannel("nightly"); - const toolkitSource = UPGRADE_SOURCES[0]!; + const toolkitSource = UPGRADE_SOURCES[0]; const requestedUrls: string[] = []; globalThis.fetch = mockFetch(async (input) => { const url = extractInputUrl(input); diff --git a/packages/cli/test/lib/wasm/helpers.ts b/packages/cli/test/lib/wasm/helpers.ts index c1379731b..501b0c323 100644 --- a/packages/cli/test/lib/wasm/helpers.ts +++ b/packages/cli/test/lib/wasm/helpers.ts @@ -72,7 +72,7 @@ export function leb128(value: number, padTo = 0): Uint8Array { bytes.push(0x00); } for (let index = 0; index < bytes.length - 1; index++) { - bytes[index] = (bytes[index] as number) | 0x80; + bytes[index] = bytes[index] | 0x80; } return Uint8Array.from(bytes); } diff --git a/packages/cli/test/lib/windows-path.test.ts b/packages/cli/test/lib/windows-path.test.ts index 300a95af4..cf6ee9325 100644 --- a/packages/cli/test/lib/windows-path.test.ts +++ b/packages/cli/test/lib/windows-path.test.ts @@ -30,7 +30,7 @@ describe("addToWindowsUserPath", () => { message: "Added C:\\Users\\me\\.local\\bin to your user PATH", manualCommand: null, }); - const [script, env] = run.mock.calls[0]!; + const [script, env] = run.mock.calls[0]; expect(env).toEqual({ SENTRY_CLI_PATH_DIR: "C:\\Users\\me\\.local\\bin", SENTRY_CLI_PATH_KEY: USER_ENVIRONMENT_KEY, diff --git a/packages/cli/test/preload.ts b/packages/cli/test/preload.ts index ddf588d87..b09623a47 100644 --- a/packages/cli/test/preload.ts +++ b/packages/cli/test/preload.ts @@ -136,7 +136,7 @@ const mockFetch = async (input: RequestInfo | URL, _init?: RequestInit) => { }; // Cast via unknown to avoid Bun's extended fetch type (which includes preconnect) -globalThis.fetch = mockFetch as unknown as typeof fetch; +globalThis.fetch = mockFetch; // Export original fetch for tests that need to restore it (globalThis as { __originalFetch?: typeof fetch }).__originalFetch = diff --git a/packages/cli/test/script/source-api-usage.test.ts b/packages/cli/test/script/source-api-usage.test.ts index c601d4605..a1ac0f5f8 100644 --- a/packages/cli/test/script/source-api-usage.test.ts +++ b/packages/cli/test/script/source-api-usage.test.ts @@ -167,7 +167,7 @@ describe("source API usage", () => { const analysis = analyzeSourceApiUsage(sources, [ ...operations, { - ...operations[0]!, + ...operations[0], functionName: "anotherEvents", path: "/api/0/organizations/{org}/events/", }, diff --git a/packages/cli/test/types/dashboard.property.test.ts b/packages/cli/test/types/dashboard.property.test.ts index f8611cb0d..0a57692b2 100644 --- a/packages/cli/test/types/dashboard.property.test.ts +++ b/packages/cli/test/types/dashboard.property.test.ts @@ -116,8 +116,8 @@ describe("property: assignDefaultLayout", () => { property(array(widgetArb, { minLength: 2, maxLength: 20 }), (widgets) => { const placed = buildPlacedSequence(widgets, "sequential"); for (let i = 1; i < placed.length; i++) { - expect(placed[i]!.layout!.y).toBeGreaterThanOrEqual( - placed[i - 1]!.layout!.y, + expect(placed[i].layout!.y).toBeGreaterThanOrEqual( + placed[i - 1].layout!.y, ); } }), diff --git a/packages/cli/test/types/dashboard.test.ts b/packages/cli/test/types/dashboard.test.ts index b40b9f875..cc376c46e 100644 --- a/packages/cli/test/types/dashboard.test.ts +++ b/packages/cli/test/types/dashboard.test.ts @@ -827,7 +827,7 @@ describe("assignDefaultLayout", () => { test("unknown displayType uses fallback size 3x2", () => { const result = assignDefaultLayout( - { title: "Custom", displayType: "some_future_type" } as DashboardWidget, + { title: "Custom", displayType: "some_future_type" }, [], ); expect(result.layout).toMatchObject({ x: 0, y: 0, w: 3, h: 2 }); @@ -874,7 +874,7 @@ describe("stripWidgetServerFields", () => { ], }; const result = stripWidgetServerFields(widget); - const query = result.queries![0]!; + const query = result.queries![0]; expect(query.id).toBe("q1"); expect(query).not.toHaveProperty("widgetId"); expect(query).not.toHaveProperty("dateCreated"); diff --git a/packages/logger/tsconfig.json b/packages/logger/tsconfig.json index d89cf4aec..7df4fae8a 100644 --- a/packages/logger/tsconfig.json +++ b/packages/logger/tsconfig.json @@ -6,6 +6,7 @@ "moduleResolution": "Bundler", "types": ["node"], "strict": true, + "noUncheckedIndexedAccess": true, "noEmit": true, "skipLibCheck": true, "isolatedModules": true diff --git a/packages/mcp-cloudflare/src/client/components/animation/TerminalAnimation.tsx b/packages/mcp-cloudflare/src/client/components/animation/TerminalAnimation.tsx index 1dcf9cc40..48f5c82b9 100644 --- a/packages/mcp-cloudflare/src/client/components/animation/TerminalAnimation.tsx +++ b/packages/mcp-cloudflare/src/client/components/animation/TerminalAnimation.tsx @@ -2,6 +2,7 @@ import "asciinema-player/dist/bundle/asciinema-player.css"; import "./dracula.css"; +import type { Marker } from "asciinema-player"; import { useCallback, useEffect, useRef, useState } from "react"; import BrowserAnimation from "./BrowserAnimation"; import KeysPaste from "./terminal-ui/keys-paste"; @@ -196,11 +197,11 @@ export default function TerminalAnimation() { } if (typeof WebAssembly === "undefined") return; - const AsciinemaPlayerLibrary = await import("asciinema-player" as any); + const AsciinemaPlayerLibrary = await import("asciinema-player"); if (!cliDemoRef.current) return; // Convert steps to markers format: [time, label] - const markers = steps.map((step) => [step.startTime, step.label]); + const markers = steps.map((step): Marker => [step.startTime, step.label]); const player = AsciinemaPlayerLibrary.create( "demo.cast", diff --git a/packages/mcp-cloudflare/src/client/components/chat/chat-message.tsx b/packages/mcp-cloudflare/src/client/components/chat/chat-message.tsx index e7429d89c..8f27b2228 100644 --- a/packages/mcp-cloudflare/src/client/components/chat/chat-message.tsx +++ b/packages/mcp-cloudflare/src/client/components/chat/chat-message.tsx @@ -162,8 +162,8 @@ const convertToolOutput = ( // If output is already in MCP format with content array if ( typeof output === "object" && - "content" in (output as object) && - Array.isArray((output as { content: unknown }).content) + "content" in output && + Array.isArray(output.content) ) { return output as { content: Array<{ type: "text"; text: string }> }; } diff --git a/packages/mcp-cloudflare/src/client/components/chat/chat.tsx b/packages/mcp-cloudflare/src/client/components/chat/chat.tsx index 51a2949ee..2b19df745 100644 --- a/packages/mcp-cloudflare/src/client/components/chat/chat.tsx +++ b/packages/mcp-cloudflare/src/client/components/chat/chat.tsx @@ -124,7 +124,7 @@ export function Chat({ isOpen, onClose, onLogout }: ChatProps) { return { name, description: def ? def.description.split("\n")[0] : "", - } as { name: string; description: string }; + }; }); content = diff --git a/packages/mcp-cloudflare/src/client/components/ui/interactive-markdown.tsx b/packages/mcp-cloudflare/src/client/components/ui/interactive-markdown.tsx index 6bd049dd6..ef7d03780 100644 --- a/packages/mcp-cloudflare/src/client/components/ui/interactive-markdown.tsx +++ b/packages/mcp-cloudflare/src/client/components/ui/interactive-markdown.tsx @@ -65,7 +65,7 @@ export function InteractiveMarkdown({ } // Regular code rendering return ( - + {children} ); diff --git a/packages/mcp-cloudflare/src/client/hooks/use-persisted-chat.ts b/packages/mcp-cloudflare/src/client/hooks/use-persisted-chat.ts index 10b0ef080..c7236c08e 100644 --- a/packages/mcp-cloudflare/src/client/hooks/use-persisted-chat.ts +++ b/packages/mcp-cloudflare/src/client/hooks/use-persisted-chat.ts @@ -37,7 +37,7 @@ function migrateMessage(msg: LegacyMessage): UIMessage { role: msg.role, parts: [{ type: "text", text: msg.content }], ...(metadata && { metadata }), - } as UIMessage; + }; } // Return as-is if neither format matches (will be filtered by validation) diff --git a/packages/mcp-cloudflare/src/server/lib/approval-dialog.ts b/packages/mcp-cloudflare/src/server/lib/approval-dialog.ts index a90dacb14..5430f7461 100644 --- a/packages/mcp-cloudflare/src/server/lib/approval-dialog.ts +++ b/packages/mcp-cloudflare/src/server/lib/approval-dialog.ts @@ -19,9 +19,7 @@ const ONE_YEAR_IN_SECONDS = 31536000; const MAX_SKILL_PREFERENCE_CLIENTS = 10; // Hosted OAuth approvals only mint active skills. Deprecated skills may still // work for existing grants or explicit stdio use, but not through this form. -const APPROVABLE_SKILLS = (skillDefinitions as SkillDefinition[]).filter( - (skill) => !skill.deprecated, -); +const APPROVABLE_SKILLS = skillDefinitions.filter((skill) => !skill.deprecated); const APPROVABLE_SKILL_IDS = new Set( APPROVABLE_SKILLS.map((skill) => skill.id), ); @@ -203,7 +201,7 @@ async function getApprovedClientsFromCookie( }); return null; } - return approvedClients as string[]; + return approvedClients; } catch (e) { logIssue( new Error(`Error parsing cookie payload: ${String(e)}`, { cause: e }), diff --git a/packages/mcp-cloudflare/src/server/lib/constraint-utils.test.ts b/packages/mcp-cloudflare/src/server/lib/constraint-utils.test.ts index d482ae405..7e35d7ce1 100644 --- a/packages/mcp-cloudflare/src/server/lib/constraint-utils.test.ts +++ b/packages/mcp-cloudflare/src/server/lib/constraint-utils.test.ts @@ -45,7 +45,7 @@ function createMockKV(options?: { delete: vi.fn(), list: vi.fn(), getWithMetadata: vi.fn(), - } as unknown as KVNamespace; + }; } /** diff --git a/packages/mcp-cloudflare/src/server/lib/mcp-handler.test.ts b/packages/mcp-cloudflare/src/server/lib/mcp-handler.test.ts index e42e37aeb..e14fd66fc 100644 --- a/packages/mcp-cloudflare/src/server/lib/mcp-handler.test.ts +++ b/packages/mcp-cloudflare/src/server/lib/mcp-handler.test.ts @@ -62,7 +62,7 @@ function createMcpContext( ...DEFAULT_OAUTH_PROPS, ...props, }, - } as ExecutionContext & { props: OAuthProps }; + }; } function createMcpRequest( @@ -582,7 +582,7 @@ describe("MCP Handler", () => { : null, ), put: vi.fn(), - } as unknown as KVNamespace; + }; const ctx = createMcpContext({ accessToken: "test-current-user-token", grantedSkills: ["inspect"], @@ -656,7 +656,7 @@ describe("MCP Handler", () => { await writeReady; stored = JSON.parse(value); }), - } as unknown as KVNamespace; + }; const ctx = Object.assign(createExecutionContext(), { props: { ...DEFAULT_OAUTH_PROPS }, }); diff --git a/packages/mcp-cloudflare/src/server/lib/mcp-handler.ts b/packages/mcp-cloudflare/src/server/lib/mcp-handler.ts index 906861fbf..01a93530a 100644 --- a/packages/mcp-cloudflare/src/server/lib/mcp-handler.ts +++ b/packages/mcp-cloudflare/src/server/lib/mcp-handler.ts @@ -572,7 +572,7 @@ const mcpHandler: ExportedHandler = { ); } - const grantedSkills = (rawProps.grantedSkills as string[]).map((skill) => + const grantedSkills = rawProps.grantedSkills.map((skill) => skill === "preprod" ? "inspect" : skill, ); const { valid: validSkills, invalid: invalidSkills } = diff --git a/packages/mcp-cloudflare/src/server/oauth/authorize.test.ts b/packages/mcp-cloudflare/src/server/oauth/authorize.test.ts index ee3df540e..45f51f714 100644 --- a/packages/mcp-cloudflare/src/server/oauth/authorize.test.ts +++ b/packages/mcp-cloudflare/src/server/oauth/authorize.test.ts @@ -77,7 +77,7 @@ async function createSkillPreferenceCookie( method: "POST", body: formData, }), - testEnv as Env, + testEnv, ); expect(response.status).toBe(302); @@ -121,7 +121,7 @@ describe("oauth authorize routes", () => { const request = new Request("http://localhost/oauth/authorize", { method: "GET", }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(200); const html = await response.text(); expect(html).toContain(" { const url = new URL("http://localhost/oauth/authorize"); if (prompt) url.searchParams.set("prompt", prompt); - const page = await app.fetch(new Request(url), testEnv as Env); + const page = await app.fetch(new Request(url), testEnv); expect(page.status).toBe(200); const html = await page.text(); expect(html).not.toContain("switch_account"); @@ -168,7 +168,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }), - testEnv as Env, + testEnv, ); expect(response.status).toBe(302); @@ -204,7 +204,7 @@ describe("oauth authorize routes", () => { const request = new Request("http://localhost/oauth/authorize", { method: "GET", }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(200); const html = await response.text(); @@ -230,7 +230,7 @@ describe("oauth authorize routes", () => { const request = new Request("http://localhost/oauth/authorize", { method: "GET", }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(400); expect(await response.text()).toBe("client_id is required"); @@ -248,7 +248,7 @@ describe("oauth authorize routes", () => { const request = new Request("http://localhost/oauth/authorize", { method: "GET", }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = new URL(response.headers.get("location")!); @@ -276,7 +276,7 @@ describe("oauth authorize routes", () => { const request = new Request("http://localhost/oauth/authorize", { method: "GET", }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(400); expect(await response.text()).toBe("Invalid redirect URI"); @@ -308,7 +308,7 @@ describe("oauth authorize routes", () => { method: "GET", headers: { Cookie: preferenceCookie }, }), - testEnv as Env, + testEnv, ); const html = await response.text(); @@ -350,7 +350,7 @@ describe("oauth authorize routes", () => { method: "GET", headers: { Cookie: preferenceCookie }, }), - testEnv as Env, + testEnv, ); const html = await response.text(); @@ -386,7 +386,7 @@ describe("oauth authorize routes", () => { )}`, }, }), - testEnv as Env, + testEnv, ); const html = await response.text(); @@ -428,7 +428,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(400); expect(await response.text()).toBe("Invalid redirect URI"); @@ -465,7 +465,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); }); @@ -494,7 +494,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); expect(location).toBeTruthy(); @@ -558,7 +558,7 @@ describe("oauth authorize routes", () => { headers: { Cookie: preferenceCookie }, body: formData, }), - testEnv as Env, + testEnv, ); expect(response.status).toBe(302); @@ -593,7 +593,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); expect(location).toBeTruthy(); @@ -628,7 +628,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); const redirectUrl = new URL(location!); @@ -660,7 +660,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); const setCookie = response.headers.get("Set-Cookie"); expect(setCookie).toBeTruthy(); expect(setCookie).toContain("mcp-approved-clients="); @@ -691,7 +691,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); expect(response.headers.get("Set-Cookie")).toBeNull(); @@ -711,7 +711,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(400); const text = await response.text(); expect(text).toBe("Invalid request"); @@ -735,7 +735,7 @@ describe("oauth authorize routes", () => { const request = new Request("http://localhost/oauth/authorize", { method: "GET", }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); // Should proceed normally (render approval dialog) expect(response.status).toBe(200); @@ -761,7 +761,7 @@ describe("oauth authorize routes", () => { "http://localhost/oauth/authorize?resource=http://localhost/mcp", { method: "GET" }, ); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); // Should proceed normally expect(response.status).toBe(200); @@ -786,7 +786,7 @@ describe("oauth authorize routes", () => { "http://localhost/oauth/authorize?resource=http://localhost", { method: "GET" }, ); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); @@ -811,7 +811,7 @@ describe("oauth authorize routes", () => { url.searchParams.set("resource", "http://localhost/"); const request = new Request(url, { method: "GET" }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); @@ -836,7 +836,7 @@ describe("oauth authorize routes", () => { url.searchParams.set("resource", "http://localhost/mcp?experimental=1"); const request = new Request(url, { method: "GET" }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(200); const html = await response.text(); @@ -866,7 +866,7 @@ describe("oauth authorize routes", () => { ); const request = new Request(url, { method: "GET" }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(200); const html = await response.text(); @@ -892,7 +892,7 @@ describe("oauth authorize routes", () => { url.searchParams.set("resource", "http://localhost/mcp/test-org"); const request = new Request(url, { method: "GET" }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(200); const html = await response.text(); @@ -919,7 +919,7 @@ describe("oauth authorize routes", () => { ); const request = new Request(url, { method: "GET" }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(200); const html = await response.text(); @@ -939,7 +939,7 @@ describe("oauth authorize routes", () => { "http://localhost/oauth/authorize?resource=https://attacker.com/mcp&redirect_uri=https://example.com/callback&state=test-state", { method: "GET" }, ); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); // Should redirect with error expect(response.status).toBe(302); @@ -966,7 +966,7 @@ describe("oauth authorize routes", () => { "http://localhost/oauth/authorize?resource=http://localhost/api&redirect_uri=https://example.com/callback", { method: "GET" }, ); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); // Should redirect with error expect(response.status).toBe(302); @@ -989,7 +989,7 @@ describe("oauth authorize routes", () => { url.searchParams.set("state", "test-state"); const request = new Request(url, { method: "GET" }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); @@ -1008,7 +1008,7 @@ describe("oauth authorize routes", () => { "http://localhost/oauth/authorize?resource=https://attacker.com/mcp", { method: "GET" }, ); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); // Should return direct error expect(response.status).toBe(400); @@ -1047,7 +1047,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); // Should proceed normally (redirect to Sentry) expect(response.status).toBe(302); @@ -1077,7 +1077,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); // Should proceed normally expect(response.status).toBe(302); @@ -1107,7 +1107,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); @@ -1137,7 +1137,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); @@ -1168,7 +1168,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); @@ -1202,7 +1202,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); @@ -1231,7 +1231,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); @@ -1261,7 +1261,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); // Should redirect with error expect(response.status).toBe(302); @@ -1296,7 +1296,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); // Should redirect with error expect(response.status).toBe(302); @@ -1328,7 +1328,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(302); const location = response.headers.get("location"); @@ -1361,7 +1361,7 @@ describe("oauth authorize routes", () => { method: "POST", body: formData, }); - const response = await app.fetch(request, testEnv as Env); + const response = await app.fetch(request, testEnv); expect(response.status).toBe(400); const text = await response.text(); diff --git a/packages/mcp-cloudflare/src/server/oauth/callback.test.ts b/packages/mcp-cloudflare/src/server/oauth/callback.test.ts index 5035d97bf..0a76c594d 100644 --- a/packages/mcp-cloudflare/src/server/oauth/callback.test.ts +++ b/packages/mcp-cloudflare/src/server/oauth/callback.test.ts @@ -104,7 +104,7 @@ async function createSignedCallbackState( }, iat: now, exp: now + 10 * 60 * 1000, - } as unknown as OAuthState; + }; return await signState(payload, COOKIE_SECRET); } @@ -319,7 +319,7 @@ describe("oauth callback routes", () => { }, iat: now, exp: now + 10 * 60 * 1000, - } as unknown as OAuthState, + }, COOKIE_SECRET, ); @@ -699,7 +699,7 @@ describe("oauth callback routes", () => { expect(callbackResponse.status).toBe(302); expect(completeAuthorization).toHaveBeenCalledOnce(); - const props = completeAuthorization.mock.calls[0]![0].props as Record< + const props = completeAuthorization.mock.calls[0][0].props as Record< string, unknown >; @@ -733,7 +733,7 @@ describe("oauth callback routes", () => { }); expect(callbackResponse.status).toBe(302); - const props = completeAuthorization.mock.calls[0]![0].props as Record< + const props = completeAuthorization.mock.calls[0][0].props as Record< string, unknown >; diff --git a/packages/mcp-cloudflare/src/server/oauth/helpers.test.ts b/packages/mcp-cloudflare/src/server/oauth/helpers.test.ts index ee30d6872..cd53d7d21 100644 --- a/packages/mcp-cloudflare/src/server/oauth/helpers.test.ts +++ b/packages/mcp-cloudflare/src/server/oauth/helpers.test.ts @@ -61,7 +61,7 @@ function createRefreshOptions( accessToken: "old-access-token", refreshToken: "old-refresh-token", ...propsOverrides, - } as WorkerProps, + }, }; } diff --git a/packages/mcp-cloudflare/src/server/oauth/routes/authorize.ts b/packages/mcp-cloudflare/src/server/oauth/routes/authorize.ts index b697ea8a7..86e2832ce 100644 --- a/packages/mcp-cloudflare/src/server/oauth/routes/authorize.ts +++ b/packages/mcp-cloudflare/src/server/oauth/routes/authorize.ts @@ -365,7 +365,7 @@ export default new Hono<{ Bindings: Env }>() // Build signed state for redirect to Sentry (10 minute validity) const now = Date.now(); const payload: OAuthState = { - req: oauthReqWithSkills as unknown as Record, + req: oauthReqWithSkills, iat: now, exp: now + 10 * 60 * 1000, }; diff --git a/packages/mcp-cloudflare/src/server/oauth/routes/callback.ts b/packages/mcp-cloudflare/src/server/oauth/routes/callback.ts index f2e997520..20a1026d8 100644 --- a/packages/mcp-cloudflare/src/server/oauth/routes/callback.ts +++ b/packages/mcp-cloudflare/src/server/oauth/routes/callback.ts @@ -290,7 +290,7 @@ export default new Hono<{ Bindings: Env }>().get("/", async (c) => { // Convert valid skills Set to array for OAuth props const grantedSkills = [...validSkills]; - const resource = (oauthReqInfo as AuthRequestWithSkills).resource; + const resource = oauthReqInfo.resource; const resourceScope = parseResourceMcpConstraints( typeof resource === "string" ? resource : undefined, ); @@ -303,7 +303,7 @@ export default new Hono<{ Bindings: Env }>().get("/", async (c) => { const userLabel = getUpstreamUserLabel(payload); const { redirectTo } = await c.env.OAUTH_PROVIDER.completeAuthorization({ - request: oauthReqInfo as AuthRequest, + request: oauthReqInfo, userId: payload.user.id, metadata: { label: userLabel, diff --git a/packages/mcp-cloudflare/src/server/routes/search.test.ts b/packages/mcp-cloudflare/src/server/routes/search.test.ts index 4b4dace2d..5f0d19be3 100644 --- a/packages/mcp-cloudflare/src/server/routes/search.test.ts +++ b/packages/mcp-cloudflare/src/server/routes/search.test.ts @@ -138,7 +138,7 @@ describe("search route", () => { body: JSON.stringify({ query: "test" }), }, { - AI: null as unknown as Ai, + AI: null, }, ); diff --git a/packages/mcp-cloudflare/src/server/routes/search.ts b/packages/mcp-cloudflare/src/server/routes/search.ts index 662c4e2c2..69d8730c8 100644 --- a/packages/mcp-cloudflare/src/server/routes/search.ts +++ b/packages/mcp-cloudflare/src/server/routes/search.ts @@ -5,7 +5,6 @@ import { SENTRY_GUIDES } from "@sentry/mcp-core/constants"; import { z } from "zod"; import type { RateLimitResult } from "../types/chat"; import type { - AutoRagSearchResponse, ComparisonFilter, CompoundFilter, AutoRagSearchRequest, @@ -167,7 +166,7 @@ export default new Hono<{ Bindings: Env }>().post("/", async (c) => { await c.env.AI.autorag(autoragId).search(searchParams); // Process search results - handle the actual response format from Cloudflare AI - const searchData = searchResult as AutoRagSearchResponse; + const searchData = searchResult; if (searchData.data?.length === 0) { logger.warn( diff --git a/packages/mcp-cloudflare/src/server/utils/rate-limiter.test.ts b/packages/mcp-cloudflare/src/server/utils/rate-limiter.test.ts index 370e8e305..5bc039562 100644 --- a/packages/mcp-cloudflare/src/server/utils/rate-limiter.test.ts +++ b/packages/mcp-cloudflare/src/server/utils/rate-limiter.test.ts @@ -24,7 +24,7 @@ describe("checkRateLimit", () => { it("allows request when rate limit not exceeded", async () => { mockRateLimiter = { limit: vi.fn().mockResolvedValue({ success: true }), - } as unknown as RateLimit; + }; const result = await checkRateLimit("192.168.1.1", mockRateLimiter, { keyPrefix: "test", @@ -41,7 +41,7 @@ describe("checkRateLimit", () => { it("denies request when rate limit exceeded", async () => { mockRateLimiter = { limit: vi.fn().mockResolvedValue({ success: false }), - } as unknown as RateLimit; + }; const result = await checkRateLimit("192.168.1.1", mockRateLimiter, { keyPrefix: "test", @@ -55,7 +55,7 @@ describe("checkRateLimit", () => { it("uses hashed identifier for privacy", async () => { mockRateLimiter = { limit: vi.fn().mockResolvedValue({ success: true }), - } as unknown as RateLimit; + }; await checkRateLimit("192.168.1.1", mockRateLimiter, { keyPrefix: "test", @@ -75,7 +75,7 @@ describe("checkRateLimit", () => { it("uses consistent hash for same identifier", async () => { mockRateLimiter = { limit: vi.fn().mockResolvedValue({ success: true }), - } as unknown as RateLimit; + }; await checkRateLimit("192.168.1.1", mockRateLimiter, { keyPrefix: "test", @@ -101,7 +101,7 @@ describe("checkRateLimit", () => { it("uses different keys for different identifiers", async () => { mockRateLimiter = { limit: vi.fn().mockResolvedValue({ success: true }), - } as unknown as RateLimit; + }; await checkRateLimit("192.168.1.1", mockRateLimiter, { keyPrefix: "test", @@ -127,7 +127,7 @@ describe("checkRateLimit", () => { it("includes key prefix in rate limit key", async () => { mockRateLimiter = { limit: vi.fn().mockResolvedValue({ success: true }), - } as unknown as RateLimit; + }; await checkRateLimit("192.168.1.1", mockRateLimiter, { keyPrefix: "mcp:ip", @@ -142,7 +142,7 @@ describe("checkRateLimit", () => { it("allows request when rate limiter throws error", async () => { mockRateLimiter = { limit: vi.fn().mockRejectedValue(new Error("Rate limiter service error")), - } as unknown as RateLimit; + }; const result = await checkRateLimit("192.168.1.1", mockRateLimiter, { keyPrefix: "test", diff --git a/packages/mcp-cloudflare/src/test-utils/configure-fetch-mock.ts b/packages/mcp-cloudflare/src/test-utils/configure-fetch-mock.ts index b0b3b986a..2197a9001 100644 --- a/packages/mcp-cloudflare/src/test-utils/configure-fetch-mock.ts +++ b/packages/mcp-cloudflare/src/test-utils/configure-fetch-mock.ts @@ -1,14 +1,11 @@ import { Response, type V4FetchHandler } from "miniflare"; import { fetch, MockAgent } from "undici"; -import { - registerFetchMockInterceptors, - type FetchMockLike, -} from "./fetch-mock-setup"; +import { registerFetchMockInterceptors } from "./fetch-mock-setup"; export function createMockOutboundService(): V4FetchHandler { const fetchMock = new MockAgent(); fetchMock.disableNetConnect(); - registerFetchMockInterceptors(fetchMock as FetchMockLike); + registerFetchMockInterceptors(fetchMock); return async (request) => { const response = await fetch(request, { dispatcher: fetchMock }); return new Response(response.body, response); diff --git a/packages/mcp-core/src/api-client/client.test.ts b/packages/mcp-core/src/api-client/client.test.ts index 1ceda5feb..3ffc8f115 100644 --- a/packages/mcp-core/src/api-client/client.test.ts +++ b/packages/mcp-core/src/api-client/client.test.ts @@ -2940,7 +2940,7 @@ describe("API query builders", () => { }, ]); expect(urls).toHaveLength(1); - const params = new URL(urls[0]!).searchParams; + const params = new URL(urls[0]).searchParams; expect(params.get("itemType")).toBe("spans"); expect(params.get("project")).toBe("123"); expect(params.get("statsPeriod")).toBe("7d"); @@ -2978,7 +2978,7 @@ describe("API query builders", () => { }); expect(urls).toHaveLength(1); - const params = new URL(urls[0]!).searchParams; + const params = new URL(urls[0]).searchParams; expect(params.get("itemType")).toBe("spans"); expect(params.get("expand")).toBe("context"); }); @@ -3614,7 +3614,7 @@ describe("API query builders", () => { }), ); expect(result.created).toBe(1); - expect(result.mappings[0]!.status).toBe("created"); + expect(result.mappings[0].status).toBe("created"); }); it("should handle updated mappings response", async () => { @@ -3647,7 +3647,7 @@ describe("API query builders", () => { }); expect(result.updated).toBe(1); - expect(result.mappings[0]!.status).toBe("updated"); + expect(result.mappings[0].status).toBe("updated"); }); }); diff --git a/packages/mcp-core/src/internal/agents/callEmbeddedAgent.test.ts b/packages/mcp-core/src/internal/agents/callEmbeddedAgent.test.ts index 1eaf8917f..43cdffe90 100644 --- a/packages/mcp-core/src/internal/agents/callEmbeddedAgent.test.ts +++ b/packages/mcp-core/src/internal/agents/callEmbeddedAgent.test.ts @@ -447,7 +447,7 @@ describe("callEmbeddedAgent", () => { vi.mocked(getAgentProvider).mockReturnValue({ type: "openrouter", label: "OpenRouter", - getModel: () => "mocked-model" as never, + getModel: () => "mocked-model", getProviderOptions: () => { throw configError; }, diff --git a/packages/mcp-core/src/internal/formatting.test.ts b/packages/mcp-core/src/internal/formatting.test.ts index cf9176e60..dbabc3848 100644 --- a/packages/mcp-core/src/internal/formatting.test.ts +++ b/packages/mcp-core/src/internal/formatting.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { SentryApiService } from "../api-client"; -import type { AutofixRunState, Event, Issue } from "../api-client/types"; +import type { Event, Issue } from "../api-client/types"; import { formatEventOutput, formatFrameHeader, @@ -291,7 +291,7 @@ describe("formatIssueOutput", () => { }, ], }, - } as AutofixRunState, + }, }); expect(output).toContain("**Summary:**"); diff --git a/packages/mcp-core/src/internal/formatting.ts b/packages/mcp-core/src/internal/formatting.ts index 2da18eb80..7ded76f06 100644 --- a/packages/mcp-core/src/internal/formatting.ts +++ b/packages/mcp-core/src/internal/formatting.ts @@ -236,11 +236,7 @@ export function formatEventOutput( }, ) { let output = ""; - const eventUser = ( - event as Event & { - user?: z.infer["user"]; - } - ).user; + const eventUser = event.user; const eventWithReplayMetadataStripped = options?.replaySummary ? stripReplayMetadata(event) : event; @@ -1527,7 +1523,7 @@ function formatN1QueryEvidence( } else if (isValidSpanArray(spansData)) { // Only show offender summaries if we have spans data but couldn't build a tree const offenderSummaries = buildOffenderSummaries( - spansData as RawSpan[], + spansData, offenderSpanIds, ); @@ -1702,7 +1698,7 @@ type MetricIssueCondition = MetricIssueEvidenceData["conditions"][number]; type Unverified = { readonly [K in keyof T]?: unknown }; function asUnverified(value: unknown): Unverified | undefined { - return isPlainObject(value) ? (value as Unverified) : undefined; + return isPlainObject(value) ? value : undefined; } type MetricAlertQuery = { @@ -2808,9 +2804,7 @@ function formatIssueReplayOutput({ } export function getReplayIdFromEvent(event: Event): string | null { - const replayContext = event.contexts?.replay as - | Record - | undefined; + const replayContext = event.contexts?.replay; const replayContextId = typeof replayContext?.replay_id === "string" ? replayContext.replay_id diff --git a/packages/mcp-core/src/internal/fresh-reads.test.ts b/packages/mcp-core/src/internal/fresh-reads.test.ts index 8e881dd86..caaf47475 100644 --- a/packages/mcp-core/src/internal/fresh-reads.test.ts +++ b/packages/mcp-core/src/internal/fresh-reads.test.ts @@ -37,7 +37,7 @@ describe("withFreshReadInput", () => { for (const args of [{ id: "a", fresh: true }, { id: "b" }]) { await tool.handler( - prepareToolParams({ tool, params: args, context }) as never, + prepareToolParams({ tool, params: args, context }), context, ); } diff --git a/packages/mcp-core/src/internal/test-fixtures.ts b/packages/mcp-core/src/internal/test-fixtures.ts index 31bd98d56..fa2028c2c 100644 --- a/packages/mcp-core/src/internal/test-fixtures.ts +++ b/packages/mcp-core/src/internal/test-fixtures.ts @@ -273,7 +273,7 @@ export class EventBuilder { build(): Event { // Cast is safe here because we ensure MutableEvent has all fields needed // for either ErrorEvent or TransactionEvent based on the type field - return { ...this.event } as Event; + return { ...this.event }; } } diff --git a/packages/mcp-core/src/internal/tool-helpers/default-organization.test.ts b/packages/mcp-core/src/internal/tool-helpers/default-organization.test.ts index a8a995bbc..abcf343db 100644 --- a/packages/mcp-core/src/internal/tool-helpers/default-organization.test.ts +++ b/packages/mcp-core/src/internal/tool-helpers/default-organization.test.ts @@ -282,7 +282,7 @@ describe("applyDefaultOrganization", () => { const context = getServerContext({ sentryHost: "sentry.io", credentialRouter: { - resolve: async () => credentials[0]!, + resolve: async () => credentials[0], list: async () => credentials, }, }); @@ -317,7 +317,7 @@ describe("applyDefaultOrganization", () => { { id: "personal", accessToken: "personal-token" }, ]; const credentialRouter: CredentialRouter = { - resolve: async () => credentials[0]!, + resolve: async () => credentials[0], list: async () => credentials, }; const context = getServerContext({ diff --git a/packages/mcp-core/src/permissions.ts b/packages/mcp-core/src/permissions.ts index d3f61f82e..329d93278 100644 --- a/packages/mcp-core/src/permissions.ts +++ b/packages/mcp-core/src/permissions.ts @@ -215,7 +215,7 @@ export function resolveScopes(options: { return expandScopes(override); } if (add) { - const base = new Set(defaults as ReadonlyArray); + const base = new Set(defaults); for (const s of add) base.add(s); return expandScopes(base); } diff --git a/packages/mcp-core/src/server.test.ts b/packages/mcp-core/src/server.test.ts index 5e8019607..f881ec013 100644 --- a/packages/mcp-core/src/server.test.ts +++ b/packages/mcp-core/src/server.test.ts @@ -148,14 +148,16 @@ describe("buildServer", () => { beforeEach(() => { vi.clearAllMocks(); startedSpans = []; - vi.mocked(startSpan).mockImplementation((( - _options: Parameters[0], - callback: (span: Span) => T, - ) => { - const span = createMockSpan(); - startedSpans.push(span); - return callback(span as unknown as Span); - }) as typeof startSpan); + vi.mocked(startSpan).mockImplementation( + ( + _options: Parameters[0], + callback: (span: Span) => T, + ) => { + const span = createMockSpan(); + startedSpans.push(span); + return callback(span as unknown as Span); + }, + ); }); const baseContext: ServerContext = { @@ -1095,12 +1097,12 @@ describe("buildServer", () => { }), ); expect( - dynamicDescription.mock.calls[0]![0].availableToolNames?.has( + dynamicDescription.mock.calls[0][0].availableToolNames?.has( "dynamic_tool", ), ).toBe(true); expect( - dynamicDescription.mock.calls[0]![0].directToolNames?.has( + dynamicDescription.mock.calls[0][0].directToolNames?.has( "dynamic_tool", ), ).toBe(true); diff --git a/packages/mcp-core/src/skills.ts b/packages/mcp-core/src/skills.ts index 17ffe4cf2..94a0cf0c7 100644 --- a/packages/mcp-core/src/skills.ts +++ b/packages/mcp-core/src/skills.ts @@ -99,7 +99,7 @@ export async function getSkillsArrayWithCounts(): Promise { } if (Array.isArray(tool.skills)) { for (const skill of tool.skills) { - counts.set(skill as Skill, (counts.get(skill as Skill) || 0) + 1); + counts.set(skill, (counts.get(skill) || 0) + 1); } } } diff --git a/packages/mcp-core/src/telem/logging.ts b/packages/mcp-core/src/telem/logging.ts index c0a5262f1..df2c0c514 100644 --- a/packages/mcp-core/src/telem/logging.ts +++ b/packages/mcp-core/src/telem/logging.ts @@ -96,7 +96,7 @@ function createSentryLogsSink(): Sink { } // Extract attributes from properties - const attributes = record.properties as Record; + const attributes = record.properties; // Map LogTape levels to sentryLogger methods // Note: sentryLogger methods are fire-and-forget and handle errors gracefully diff --git a/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts b/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts index 3788f0df0..0a583f358 100644 --- a/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts +++ b/packages/mcp-core/src/tools/catalog/analyze-issue-with-seer.ts @@ -106,7 +106,7 @@ export default defineTool({ const issue = await apiService.getIssue({ organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, }); assertIssueWithinProjectConstraint({ @@ -125,7 +125,7 @@ export default defineTool({ () => apiService.getAutofixState({ organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, }), { maxRetries: SEER_MAX_RETRIES, @@ -157,7 +157,7 @@ export default defineTool({ () => apiService.getAutofixState({ organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, }), { maxRetries: SEER_MAX_RETRIES, @@ -241,7 +241,7 @@ export default defineTool({ () => apiService.getAutofixState({ organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, }), { maxRetries: SEER_MAX_RETRIES, diff --git a/packages/mcp-core/src/tools/catalog/find-dashboards.test.ts b/packages/mcp-core/src/tools/catalog/find-dashboards.test.ts index c4c397ae9..000ffdf26 100644 --- a/packages/mcp-core/src/tools/catalog/find-dashboards.test.ts +++ b/packages/mcp-core/src/tools/catalog/find-dashboards.test.ts @@ -233,9 +233,9 @@ describe("find_dashboards", () => { ); expect(requestUrls).toHaveLength(2); - expect(new URL(requestUrls[0]!).searchParams.get("per_page")).toBe("2"); - expect(new URL(requestUrls[1]!).searchParams.get("cursor")).toBe("page-2"); - expect(new URL(requestUrls[1]!).searchParams.get("per_page")).toBe("2"); + expect(new URL(requestUrls[0]).searchParams.get("per_page")).toBe("2"); + expect(new URL(requestUrls[1]).searchParams.get("cursor")).toBe("page-2"); + expect(new URL(requestUrls[1]).searchParams.get("per_page")).toBe("2"); assertStructuredOnlyResult(result); const structuredContent = findDashboardsOutputSchema.parse( getStructuredContent(result), @@ -363,8 +363,8 @@ describe("find_dashboards", () => { projectConstrainedContext, ); - expect(new URL(requestUrls[2]!).searchParams.get("cursor")).toBe("page-2"); - expect(new URL(requestUrls[2]!).searchParams.get("per_page")).toBe("2"); + expect(new URL(requestUrls[2]).searchParams.get("cursor")).toBe("page-2"); + expect(new URL(requestUrls[2]).searchParams.get("per_page")).toBe("2"); assertStructuredOnlyResult(secondResult); expect(getStructuredContent(secondResult)).toMatchObject({ dashboards: [{ id: "304", title: "Cloudflare Throughput" }], diff --git a/packages/mcp-core/src/tools/catalog/get-agent-conversation-details.ts b/packages/mcp-core/src/tools/catalog/get-agent-conversation-details.ts index 3a78de973..9b45fd470 100644 --- a/packages/mcp-core/src/tools/catalog/get-agent-conversation-details.ts +++ b/packages/mcp-core/src/tools/catalog/get-agent-conversation-details.ts @@ -563,7 +563,7 @@ function buildMessageEvents(span: AIConversationSpan): ConversationMessage[] { }); } else if (events.length > 0) { events[events.length - 1] = { - ...events[events.length - 1]!, + ...events[events.length - 1], metadata, genAi, }; diff --git a/packages/mcp-core/src/tools/catalog/get-issue-activity.test.ts b/packages/mcp-core/src/tools/catalog/get-issue-activity.test.ts index f18d3b93d..915729be8 100644 --- a/packages/mcp-core/src/tools/catalog/get-issue-activity.test.ts +++ b/packages/mcp-core/src/tools/catalog/get-issue-activity.test.ts @@ -156,7 +156,7 @@ describe("get_issue_activity", () => { }, data: { text: "Investigating after the latest deploy." }, backendOnlyField: "must-not-leak", - } as IssueActivity); + }); const result = await getIssueActivity.handler(params, context); const structuredContent = getStructuredContent(result); @@ -208,7 +208,7 @@ describe("get_issue_activity", () => { assigneeName: "Sam Owner", assigneeType: "user", }, - } as IssueActivity); + }); const result = await getIssueActivity.handler( { ...params, includeComments: false }, @@ -454,12 +454,12 @@ describe("get_issue_activity", () => { deletedPr, blankCommit, ] = activity; - expect(unmerge!.unmerge).toEqual({ + expect(unmerge.unmerge).toEqual({ fingerprintCount: 2, source: { shortId: "CLOUDFLARE-MCP-42" }, destination: null, }); - expect(Object.keys(resolved!).sort()).toEqual([ + expect(Object.keys(resolved).sort()).toEqual([ "author", "commentId", "dateCreated", @@ -467,18 +467,18 @@ describe("get_issue_activity", () => { "text", "type", ]); - expect(rca!.text).toBe("Null org slug reaches the API client."); - expect(seerPr!.pullRequestUrls).toEqual([ + expect(rca.text).toBe("Null org slug reaches the API client."); + expect(seerPr.pullRequestUrls).toEqual([ "https://github.com/getsentry/sentry-mcp/pull/7", ]); - expect(createIssue!.externalIssue).toEqual({ + expect(createIssue.externalIssue).toEqual({ title: "Fix null org", provider: "Jira", location: "https://example.atlassian.net/browse/ENG-1", }); - expect(resolvedByAge!.age).toBe(720); - expect(deletedPr!.pullRequest).toBeNull(); - expect(blankCommit!.commit).toMatchObject({ id: "abc123", message: null }); + expect(resolvedByAge.age).toBe(720); + expect(deletedPr.pullRequest).toBeNull(); + expect(blankCommit.commit).toMatchObject({ id: "abc123", message: null }); const serialized = JSON.stringify(structuredContent); for (const leaked of [ @@ -505,7 +505,7 @@ describe("get_issue_activity", () => { assigneeName: "jane@corp.com", assigneeType: "user", }, - } as IssueActivity); + }); const result = await getIssueActivity.handler( { ...params, includeComments: false }, @@ -514,7 +514,7 @@ describe("get_issue_activity", () => { const [assigned] = getStructuredContent<{ activity: Array<{ assignee?: { name: string | null } }>; }>(result).activity; - expect(assigned!.assignee).toEqual({ + expect(assigned.assignee).toEqual({ id: "43", type: "user", name: "jane@corp.com", diff --git a/packages/mcp-core/src/tools/catalog/get-issue-breadcrumbs.test.ts b/packages/mcp-core/src/tools/catalog/get-issue-breadcrumbs.test.ts index 1f7d0a409..71adbc2de 100644 --- a/packages/mcp-core/src/tools/catalog/get-issue-breadcrumbs.test.ts +++ b/packages/mcp-core/src/tools/catalog/get-issue-breadcrumbs.test.ts @@ -223,7 +223,7 @@ describe("get_issue_breadcrumbs", () => { ); const [crumb] = getStructuredContent(result).breadcrumbs; - expect(Object.keys(crumb!).sort()).toEqual([ + expect(Object.keys(crumb).sort()).toEqual([ "category", "data", "level", @@ -237,9 +237,9 @@ describe("get_issue_breadcrumbs", () => { category: null, type: "default", }); - expect(crumb!.message).toMatch(/^line one line two x+\.\.\.$/); - expect((crumb!.message as string).length).toBe(123); - expect((crumb!.data as string).length).toBe(203); + expect(crumb.message).toMatch(/^line one line two x+\.\.\.$/); + expect((crumb.message as string).length).toBe(123); + expect((crumb.data as string).length).toBe(203); expect(JSON.stringify(crumb)).not.toContain("must-not-leak"); }); }); diff --git a/packages/mcp-core/src/tools/catalog/get-issue-details.ts b/packages/mcp-core/src/tools/catalog/get-issue-details.ts index 5163a6dbd..89e15f0f2 100644 --- a/packages/mcp-core/src/tools/catalog/get-issue-details.ts +++ b/packages/mcp-core/src/tools/catalog/get-issue-details.ts @@ -522,7 +522,7 @@ export default defineTool({ try { issue = await apiService.getIssue({ organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, }); } catch (error) { if (error instanceof ApiNotFoundError) { diff --git a/packages/mcp-core/src/tools/catalog/get-issue-tag-values.ts b/packages/mcp-core/src/tools/catalog/get-issue-tag-values.ts index 01d522e97..a68ac9619 100644 --- a/packages/mcp-core/src/tools/catalog/get-issue-tag-values.ts +++ b/packages/mcp-core/src/tools/catalog/get-issue-tag-values.ts @@ -126,7 +126,7 @@ export default defineTool({ await ensureIssueWithinProjectConstraint({ apiService, organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, projectSlug: context.constraints.projectSlug, }); @@ -135,7 +135,7 @@ export default defineTool({ try { tagValues = await apiService.getIssueTagValues({ organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, tagKey: params.tagKey, }); } catch (error) { @@ -143,7 +143,7 @@ export default defineTool({ throw await explainTagValuesNotFound({ apiService, organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, tagKey: params.tagKey, error, }); diff --git a/packages/mcp-core/src/tools/catalog/get-snapshot-image.test.ts b/packages/mcp-core/src/tools/catalog/get-snapshot-image.test.ts index 50ab80113..7bcbd9464 100644 --- a/packages/mcp-core/src/tools/catalog/get-snapshot-image.test.ts +++ b/packages/mcp-core/src/tools/catalog/get-snapshot-image.test.ts @@ -147,24 +147,24 @@ describe("get_snapshot_image", () => { it("returns preview text and image parts for a changed comparison", async () => { setupChangedImageMocks(); - const result = (await callHandler()) as (TextContent | ImageContent)[]; + const result = await callHandler(); const { textParts, imageParts } = splitParts(result); - expect(textParts[0]!.text).toContain("## login_screen.png"); - expect(textParts[0]!.text).toContain( + expect(textParts[0].text).toContain("## login_screen.png"); + expect(textParts[0].text).toContain( "- **URL**: https://sentry.sentry.io/preprod/snapshots/231949/?selectedSnapshot=login_screen.png", ); - expect(textParts[0]!.text).toContain("**Status**: changed"); - expect(textParts[0]!.text).toContain("**Diff**: 12.5%"); - expect(textParts[0]!.text).toContain("**Image Resolution**: preview"); - expect(textParts[0]!.text).toContain( + expect(textParts[0].text).toContain("**Status**: changed"); + expect(textParts[0].text).toContain("**Diff**: 12.5%"); + expect(textParts[0].text).toContain("**Image Resolution**: preview"); + expect(textParts[0].text).toContain( "Use the Sentry tool `get_snapshot_image` for full-resolution image bytes", ); - expect(textParts[0]!.text).toContain("### Context"); - expect(textParts[0]!.text).toContain("- **device_name**: iPhone 16"); - expect(textParts[1]!.text).toBe("### Head (current) — preview"); - expect(textParts[2]!.text).toBe("### Base (previous) — preview"); - expect(textParts[3]!.text).toBe("### Diff Mask — preview"); + expect(textParts[0].text).toContain("### Context"); + expect(textParts[0].text).toContain("- **device_name**: iPhone 16"); + expect(textParts[1].text).toBe("### Head (current) — preview"); + expect(textParts[2].text).toBe("### Base (previous) — preview"); + expect(textParts[3].text).toBe("### Diff Mask — preview"); expect(textParts.map((part) => part.text)).toMatchInlineSnapshot(` [ "## login_screen.png @@ -190,8 +190,8 @@ describe("get_snapshot_image", () => { ] `); expect(imageParts).toHaveLength(3); - expect(imageParts[0]!.mimeType).toBe("image/png"); - expect(imageParts[1]!.mimeType).toBe("image/png"); + expect(imageParts[0].mimeType).toBe("image/png"); + expect(imageParts[1].mimeType).toBe("image/png"); }); it("downsamples 16-bit PNGs in preview responses", async () => { @@ -216,17 +216,17 @@ describe("get_snapshot_image", () => { ), ); - const result = (await callHandler()) as (TextContent | ImageContent)[]; + const result = await callHandler(); const { textParts, imageParts } = splitParts(result); - expect(textParts[1]!.text).toBe("### Head (current) — preview"); + expect(textParts[1].text).toBe("### Head (current) — preview"); expect(imageParts).toHaveLength(1); - expect(imageParts[0]!.mimeType).toBe("image/png"); - expect(imageParts[0]!.data).not.toBe( + expect(imageParts[0].mimeType).toBe("image/png"); + expect(imageParts[0].data).not.toBe( Buffer.from(largeSixteenBitPng).toString("base64"), ); - const decoded = decodePng(Buffer.from(imageParts[0]!.data, "base64")); + const decoded = decodePng(Buffer.from(imageParts[0].data, "base64")); expect(decoded.width).toBe(1024); expect(decoded.height).toBe(512); expect(decoded.depth).toBe(8); @@ -235,15 +235,15 @@ describe("get_snapshot_image", () => { it("returns original bytes when full resolution is requested", async () => { setupChangedImageMocks(); - const result = (await callHandler({ + const result = await callHandler({ imageResolution: "full", - })) as (TextContent | ImageContent)[]; + }); const { textParts, imageParts } = splitParts(result); - expect(textParts[0]!.text).toContain("**Image Resolution**: full"); - expect(textParts[1]!.text).toBe("### Head (current) — full"); - expect(imageParts[0]!.data).toBe(Buffer.from(fakePng).toString("base64")); - expect(imageParts[1]!.data).toBe(Buffer.from(fakePng).toString("base64")); + expect(textParts[0].text).toContain("**Image Resolution**: full"); + expect(textParts[1].text).toBe("### Head (current) — full"); + expect(imageParts[0].data).toBe(Buffer.from(fakePng).toString("base64")); + expect(imageParts[1].data).toBe(Buffer.from(fakePng).toString("base64")); }); it("throws on missing explicit snapshot params", async () => { @@ -291,10 +291,10 @@ describe("get_snapshot_image", () => { ), ); - const result = (await callHandler()) as (TextContent | ImageContent)[]; + const result = await callHandler(); const { textParts, imageParts } = splitParts(result); - expect(textParts[1]!.text).toBe( + expect(textParts[1].text).toBe( "### Head (current) — preview unavailable. Retry with imageResolution=full to fetch the original image.", ); expect(imageParts).toHaveLength(0); @@ -327,13 +327,13 @@ describe("get_snapshot_image", () => { ), ); - const result = (await callHandler({ + const result = await callHandler({ imageIdentifier: slashImageIdentifier, - })) as (TextContent | ImageContent)[]; + }); const { textParts } = splitParts(result); - expect(textParts[0]!.text).toContain(`## ${slashImageIdentifier}`); - expect(textParts[0]!.text).toContain( + expect(textParts[0].text).toContain(`## ${slashImageIdentifier}`); + expect(textParts[0].text).toContain( `- **File**: \`${slashImageIdentifier}\``, ); }); @@ -341,10 +341,10 @@ describe("get_snapshot_image", () => { it("detects image type from magic bytes when content-type is octet-stream", async () => { setupChangedImageMocks({ contentType: "application/octet-stream" }); - const result = (await callHandler()) as (TextContent | ImageContent)[]; + const result = await callHandler(); const { imageParts } = splitParts(result); - expect(imageParts[0]!.mimeType).toBe("image/png"); + expect(imageParts[0].mimeType).toBe("image/png"); }); it("throws when no image data is available", async () => { diff --git a/packages/mcp-core/src/tools/catalog/search-agent-conversations.test.ts b/packages/mcp-core/src/tools/catalog/search-agent-conversations.test.ts index 4c00ae3c1..425d66db6 100644 --- a/packages/mcp-core/src/tools/catalog/search-agent-conversations.test.ts +++ b/packages/mcp-core/src/tools/catalog/search-agent-conversations.test.ts @@ -199,7 +199,7 @@ describe("search_agent_conversations", () => { sampleTraceIds: string[]; }>; }>(result); - const conversation = structuredContent.conversations[0]!; + const conversation = structuredContent.conversations[0]; expect(conversation.firstInputPreview).toHaveLength(240); expect(conversation.firstInputPreview?.endsWith("...")).toBe(true); @@ -315,7 +315,7 @@ describe("search_agent_conversations", () => { getServerContext(), ); - const params = new URL(requestUrls[0]!).searchParams; + const params = new URL(requestUrls[0]).searchParams; expect(params.get("query")).toBe("failed"); expect(params.get("sort")).toBe(null); expect(params.getAll("project")).toEqual(["4509109107622913"]); diff --git a/packages/mcp-core/src/tools/catalog/update-issue.ts b/packages/mcp-core/src/tools/catalog/update-issue.ts index 96832756c..7e26da7c4 100644 --- a/packages/mcp-core/src/tools/catalog/update-issue.ts +++ b/packages/mcp-core/src/tools/catalog/update-issue.ts @@ -779,7 +779,7 @@ export default defineTool({ // Get current issue details first const currentIssue = await apiService.getIssue({ organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, }); assertIssueWithinProjectConstraint({ issue: currentIssue, @@ -843,7 +843,7 @@ export default defineTool({ const commentResult = await tryPostReasonComment( apiService, orgSlug, - parsedIssueId!, + parsedIssueId, params.reason, ); @@ -863,7 +863,7 @@ export default defineTool({ // Update the issue const updatedIssue = await apiService.updateIssue({ organizationSlug: orgSlug, - issueId: parsedIssueId!, + issueId: parsedIssueId, status: updateStatus, assignedTo: updateAssignedTo, substatus: updateIgnore?.substatus, @@ -877,7 +877,7 @@ export default defineTool({ const commentResult = await tryPostReasonComment( apiService, orgSlug, - parsedIssueId!, + parsedIssueId, params.reason, ); diff --git a/packages/mcp-core/src/tools/catalog/update-uptime-monitor.test.ts b/packages/mcp-core/src/tools/catalog/update-uptime-monitor.test.ts index 16feb51c7..8d08e95e6 100644 --- a/packages/mcp-core/src/tools/catalog/update-uptime-monitor.test.ts +++ b/packages/mcp-core/src/tools/catalog/update-uptime-monitor.test.ts @@ -169,7 +169,7 @@ describe("update_uptime_monitor", () => { expect(requestBody).toEqual({ owner: null }); assertStructuredOnlyResult(result); expect( - (getStructuredContent(result) as { monitor: { owner?: string } }).monitor + getStructuredContent<{ monitor: { owner?: string } }>(result).monitor .owner, ).toBeUndefined(); }); diff --git a/packages/mcp-core/src/tools/support/dashboards/index.ts b/packages/mcp-core/src/tools/support/dashboards/index.ts index 3a33b4f83..bf497e76d 100644 --- a/packages/mcp-core/src/tools/support/dashboards/index.ts +++ b/packages/mcp-core/src/tools/support/dashboards/index.ts @@ -317,7 +317,7 @@ export async function resolveDashboardId({ } while (cursor); if (exactMatches.length === 1) { - return String(exactMatches[0]!.id); + return String(exactMatches[0].id); } if (exactMatches.length > 1) { diff --git a/packages/mcp-core/src/tools/support/event-stacktrace.ts b/packages/mcp-core/src/tools/support/event-stacktrace.ts index f54fdf503..8b758abb8 100644 --- a/packages/mcp-core/src/tools/support/event-stacktrace.ts +++ b/packages/mcp-core/src/tools/support/event-stacktrace.ts @@ -133,7 +133,7 @@ function selectSentryDefaultThread(threads: Thread[]): Thread { return ( sortedThreads.find((thread) => thread.crashed) ?? sortedThreads.find((thread) => hasFrames(thread)) ?? - sortedThreads[0]! + sortedThreads[0] ); } @@ -159,7 +159,7 @@ function selectUnique( return { kind: "selected", - thread: matches[0]!, + thread: matches[0], reason: "Matched the provided thread selector.", }; } diff --git a/packages/mcp-core/src/tools/support/issue-linking/app.test.ts b/packages/mcp-core/src/tools/support/issue-linking/app.test.ts index 6276e6d62..f49d25643 100644 --- a/packages/mcp-core/src/tools/support/issue-linking/app.test.ts +++ b/packages/mcp-core/src/tools/support/issue-linking/app.test.ts @@ -27,8 +27,12 @@ const linkForm = { function mockDiscovery({ slug = "linear", - form = linkForm as Record, - links = [] as (typeof association)[], + form = linkForm, + links = [], +}: { + slug?: string; + form?: Record; + links?: (typeof association)[]; } = {}) { mswServer.use( http.get(`${base}/organizations/example/sentry-app-installations/`, () => diff --git a/packages/mcp-core/src/tools/support/issue-linking/app.ts b/packages/mcp-core/src/tools/support/issue-linking/app.ts index ce193039c..0e2a28493 100644 --- a/packages/mcp-core/src/tools/support/issue-linking/app.ts +++ b/packages/mcp-core/src/tools/support/issue-linking/app.ts @@ -61,7 +61,7 @@ function isIssueKey(value: string, key: string): boolean { function choiceLabelKey(label: string | number): string { return String(label) .toUpperCase() - .split(/[^A-Z0-9-]+/)[0]!; + .split(/[^A-Z0-9-]+/)[0]; } function parseTarget(raw: string) { @@ -217,7 +217,7 @@ async function resolveFields( ? Object.fromEntries( dependencies.map((dependency) => [ dependency, - values[dependency]!, + values[dependency], ]), ) : undefined, @@ -241,7 +241,7 @@ async function resolveFields( ); } if (targetKey) { - const [selectedValue, selectedLabel] = matches[0]!; + const [selectedValue, selectedLabel] = matches[0]; const valueKey = String(selectedValue).toUpperCase(); const labelKey = choiceLabelKey(selectedLabel); const identifiedChoices = choices.filter( @@ -263,7 +263,7 @@ async function resolveFields( ); } } - value = matches[0]![0]; + value = matches[0][0]; } else { value ??= search; if ( @@ -319,7 +319,7 @@ export async function linkAppIssue( ); if (installed.length !== 1) throw new UserInputError(`Expected one installed Sentry App '${appSlug}'.`); - const installation = installed[0]!; + const installation = installed[0]; const matchingComponents = components.filter( (component) => component.type === "issue-link" && diff --git a/packages/mcp-core/src/tools/support/issue-linking/index.ts b/packages/mcp-core/src/tools/support/issue-linking/index.ts index e3e0f7cb2..9dab9a121 100644 --- a/packages/mcp-core/src/tools/support/issue-linking/index.ts +++ b/packages/mcp-core/src/tools/support/issue-linking/index.ts @@ -86,7 +86,7 @@ function nativeIdentity( /^\/([^/]+\/[^/]+)\/(issues|pull)\/(\d+)(?:\/(files|changes|commits|checks))?$/, ); if (!match || (match[2] === "issues" && match[4])) return undefined; - return `${url.origin}/${match[1]!.toLowerCase()}#${match[3]}`; + return `${url.origin}/${match[1].toLowerCase()}#${match[3]}`; } case "gitlab": { const match = path.match(/^\/(.+?)(?:\/-)?\/issues\/(\d+)$/); @@ -262,7 +262,7 @@ export async function linkExternalIssue( `Multiple installed issue integrations match this URL. Provide integrationId to select one: ${describeIntegrations(candidates)}.`, ); } - const integration = candidates[0]!; + const integration = candidates[0]; const { issue, changed } = await apiService.linkNativeExternalIssue({ ...params, integrationId: String(integration.id), diff --git a/packages/mcp-core/src/tools/support/profile/details-output.test.ts b/packages/mcp-core/src/tools/support/profile/details-output.test.ts index bdd4dfd04..661b53c8c 100644 --- a/packages/mcp-core/src/tools/support/profile/details-output.test.ts +++ b/packages/mcp-core/src/tools/support/profile/details-output.test.ts @@ -56,7 +56,7 @@ function createMockProfileChunk(): ProfileChunk { "2": { name: "worker" }, }, }, - } as ProfileChunk; + }; } function createMockTransactionProfile(): TransactionProfile { diff --git a/packages/mcp-core/src/tools/support/profile/details-output.ts b/packages/mcp-core/src/tools/support/profile/details-output.ts index 13062213f..0d7d5cd2f 100644 --- a/packages/mcp-core/src/tools/support/profile/details-output.ts +++ b/packages/mcp-core/src/tools/support/profile/details-output.ts @@ -216,7 +216,7 @@ function getTransactionProfileDurationNs( return null; } - const duration = elapsed[elapsed.length - 1]! - elapsed[0]!; + const duration = elapsed[elapsed.length - 1] - elapsed[0]; return duration > 0 ? Math.round(duration) : null; } diff --git a/packages/mcp-core/src/tools/support/profile/flamegraph-output.test.ts b/packages/mcp-core/src/tools/support/profile/flamegraph-output.test.ts index bba696664..04923ac55 100644 --- a/packages/mcp-core/src/tools/support/profile/flamegraph-output.test.ts +++ b/packages/mcp-core/src/tools/support/profile/flamegraph-output.test.ts @@ -137,7 +137,7 @@ describe("buildFlamegraphAnalysis", () => { it("maps placeholder file and line values to null", () => { const flamegraph = createMockFlamegraph(); flamegraph.shared.frames[0] = { - ...flamegraph.shared.frames[0]!, + ...flamegraph.shared.frames[0], file: "", line: 0, }; @@ -223,7 +223,7 @@ describe("buildFlamegraphComparison", () => { it("detects major regressions", () => { const current = createMockFlamegraph(); // Comparison uses sumDuration, not weight. - current.shared.frame_infos[0]!.sumDuration = 240_000_000; + current.shared.frame_infos[0].sumDuration = 240_000_000; const comparison = buildFlamegraphComparison( createMockFlamegraph(), @@ -248,7 +248,7 @@ describe("buildFlamegraphComparison", () => { const withPlaceholders = () => { const flamegraph = createMockFlamegraph(); flamegraph.shared.frames[0] = { - ...flamegraph.shared.frames[0]!, + ...flamegraph.shared.frames[0], file: "", line: 0, }; @@ -269,7 +269,7 @@ describe("buildFlamegraphComparison", () => { it("keeps improvements in changes when many frames are unchanged", () => { const withFrames = (improvedDurationNs: number) => { const flamegraph = createMockFlamegraph(); - const template = flamegraph.shared.frame_infos[0]!; + const template = flamegraph.shared.frame_infos[0]; flamegraph.shared.frames = Array.from({ length: 13 }, (_, index) => ({ file: `module_${index}.py`, name: `fn_${index}`, @@ -303,9 +303,9 @@ describe("buildFlamegraphComparison", () => { it("detects improvements", () => { const current = createMockFlamegraph(); - current.shared.frame_infos[0]!.sumDuration = 128_000_000; - current.shared.frame_infos[1]!.sumDuration = 128_000_000; - current.shared.frame_infos[2]!.sumDuration = 80_000_000; + current.shared.frame_infos[0].sumDuration = 128_000_000; + current.shared.frame_infos[1].sumDuration = 128_000_000; + current.shared.frame_infos[2].sumDuration = 80_000_000; expect( buildFlamegraphComparison(createMockFlamegraph(), current, { diff --git a/packages/mcp-core/src/tools/support/search-events/dropped-events-note.test.ts b/packages/mcp-core/src/tools/support/search-events/dropped-events-note.test.ts index 2bd988bbd..9e103f3cf 100644 --- a/packages/mcp-core/src/tools/support/search-events/dropped-events-note.test.ts +++ b/packages/mcp-core/src/tools/support/search-events/dropped-events-note.test.ts @@ -137,7 +137,7 @@ describe("buildDroppedEventsNote", () => { await buildDroppedEventsNote({ ...base, apiService, - dataset: "profiles" as never, + dataset: "profiles", }), ).toBe(""); }); diff --git a/packages/mcp-core/src/tools/support/search-events/search.ts b/packages/mcp-core/src/tools/support/search-events/search.ts index 2f070b83f..d92af61c7 100644 --- a/packages/mcp-core/src/tools/support/search-events/search.ts +++ b/packages/mcp-core/src/tools/support/search-events/search.ts @@ -1107,7 +1107,7 @@ async function executeSearchEvents( apiService, organizationSlug, projectId, - dataset: dataset as PublicEventsDataset, + dataset: dataset, interval: timeSeries.interval, timeParams, toolAvailable: diff --git a/packages/mcp-core/src/tools/support/search-events/utils.test.ts b/packages/mcp-core/src/tools/support/search-events/utils.test.ts index a7b9244fa..426628738 100644 --- a/packages/mcp-core/src/tools/support/search-events/utils.test.ts +++ b/packages/mcp-core/src/tools/support/search-events/utils.test.ts @@ -79,8 +79,8 @@ describe("validateSearch tool contract", () => { }); expect(requests).toHaveLength(1); - expect(requests[0]!.getAll("environment")).toEqual([]); - expect(requests[0]!.get("query")).toBe(query); + expect(requests[0].getAll("environment")).toEqual([]); + expect(requests[0].get("query")).toBe(query); expect(result).toEqual({ result: { valid: true, message: "Search validation passed." }, }); @@ -1136,7 +1136,7 @@ describe("fetchCustomAttributes", () => { ); expect(requests).toHaveLength(1); - expect(requests[0]!.get("attributeType")).toBeNull(); + expect(requests[0].get("attributeType")).toBeNull(); for (const params of requests) { expect(params.get("itemType")).toBe("spans"); expect(params.get("project")).toBe("123"); diff --git a/packages/mcp-core/src/transports/stdio.test.ts b/packages/mcp-core/src/transports/stdio.test.ts index 913efd028..476a57399 100644 --- a/packages/mcp-core/src/transports/stdio.test.ts +++ b/packages/mcp-core/src/transports/stdio.test.ts @@ -17,7 +17,7 @@ const server = { async function spanAttributes(context: Parameters[1]) { await startStdio(server, context); - const [options] = vi.mocked(startSpan).mock.calls[0]!; + const [options] = vi.mocked(startSpan).mock.calls[0]; return options.attributes; } diff --git a/packages/mcp-core/src/utils/url-utils.ts b/packages/mcp-core/src/utils/url-utils.ts index 6bbfb0885..25dfb5cb3 100644 --- a/packages/mcp-core/src/utils/url-utils.ts +++ b/packages/mcp-core/src/utils/url-utils.ts @@ -109,8 +109,8 @@ function extractTraceMetricFromAggregate( } return normalizeTraceMetric({ - name: args[1]!, - type: args[2]!, + name: args[1], + type: args[2], unit: args[3], }); } diff --git a/packages/mcp-server-mocks/src/fixtures.ts b/packages/mcp-server-mocks/src/fixtures.ts index b050341e3..c7ed3ee49 100644 --- a/packages/mcp-server-mocks/src/fixtures.ts +++ b/packages/mcp-server-mocks/src/fixtures.ts @@ -61,7 +61,7 @@ function deepMerge(target: T, source: DeepPartial): T { if (isObject(target) && isObject(source)) { for (const key of Object.keys(source)) { const sourceValue = (source as any)[key]; - const targetValue = (output as any)[key]; + const targetValue = output[key]; if ( isObject(sourceValue) && diff --git a/packages/mcp-test-client/src/agent.ts b/packages/mcp-test-client/src/agent.ts index ec9889ac9..381a5b28b 100644 --- a/packages/mcp-test-client/src/agent.ts +++ b/packages/mcp-test-client/src/agent.ts @@ -57,7 +57,7 @@ function findApiCallError(error: unknown): APICallError | undefined { return findApiCallError(error.lastError); } if (error && typeof error === "object" && "cause" in error && error.cause) { - return findApiCallError((error as { cause: unknown }).cause); + return findApiCallError(error.cause); } return undefined; } diff --git a/packages/toolkit-core/tsconfig.json b/packages/toolkit-core/tsconfig.json index 741fa77f1..9fc6f4c61 100644 --- a/packages/toolkit-core/tsconfig.json +++ b/packages/toolkit-core/tsconfig.json @@ -4,6 +4,7 @@ "module": "ESNext", "moduleResolution": "Bundler", "strict": true, + "noUncheckedIndexedAccess": true, "noEmit": true, "skipLibCheck": true },