Skip to content

feat: remove 25 response-type as unknown as casts from API layer#1090

Merged
MathurAditya724 merged 2 commits into
mainfrom
issue-1068-migrate-sentry-api-sdk-types
Jun 10, 2026
Merged

feat: remove 25 response-type as unknown as casts from API layer#1090
MathurAditya724 merged 2 commits into
mainfrom
issue-1068-migrate-sentry-api-sdk-types

Conversation

@jared-outpost

@jared-outpost jared-outpost Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Phase 1 of #1068 — eliminates all response-type as unknown as casts from src/lib/api/ by widening unwrapResult<T> and unwrapPaginatedResult<T> to accept { data: unknown } instead of { data: T }. Callers now specify the target type via the generic parameter rather than casting the return value, centralizing the single data as T cast in infrastructure.ts.

Cast count: 31 → 8 (the remaining 8 are request-body casts, undocumented-query-param casts, and path-parameter casts for non-numeric dashboard slugs that require backend spec changes).

Also:

  • Removes redundant result as casts at unwrapPaginatedResult call sites
  • Downgrades data.event as unknown as SentryEvent to a single as SentryEvent in resolveEventInOrg

Testing

tsc --noEmit passes (only pre-existing errors from missing generated files). biome check passes clean.

Closes #1068

Widen unwrapResult<T> and unwrapPaginatedResult<T> to accept
`{ data: unknown }` instead of `{ data: T }`, so callers specify
the target type via the generic parameter rather than casting the
return value. This eliminates all response-type casts while keeping
the single `data as T` cast centralized in infrastructure.ts.

Also replaces 2 dashboard_id path-parameter casts with
Number.parseInt() and removes redundant result-argument casts at
unwrapPaginatedResult call sites.

Remaining 6 casts are request-body and undocumented-query-param
casts that require backend spec changes (Categories 2-3 in #1068).

Fixes #1068
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1090/

Built to branch gh-pages at 2026-06-10 16:38 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

❌ Patch coverage is 76.92%. Project has 5015 uncovered lines.
✅ Project coverage is 81.17%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
src/lib/api/dashboards.ts 0.00% ⚠️ 3 Missing
src/lib/api/releases.ts 71.43% ⚠️ 2 Missing
src/lib/api/monitors.ts 0.00% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.17%    81.17%        —%
==========================================
  Files          383       383         —
  Lines        26659     26640       -19
  Branches     17338     17338         —
==========================================
+ Hits         21640     21625       -15
- Misses        5019      5015        -4
- Partials      1796      1796         —

Generated by Codecov Action

Comment thread src/lib/api/dashboards.ts Outdated
@MathurAditya724 MathurAditya724 added jared Trigger the Jared agent to work on stuff and removed jared Trigger the Jared agent to work on stuff labels Jun 10, 2026
@MathurAditya724

Copy link
Copy Markdown
Member

test webhook

…lugs

Number.parseInt('default-overview', 10) returns NaN, breaking the
request path for slug-based dashboard IDs. The original as-cast was
correct — it's a compile-time lie that lets the string pass through
at runtime, which the API accepts.
@MathurAditya724 MathurAditya724 marked this pull request as ready for review June 10, 2026 17:03
@MathurAditya724 MathurAditya724 merged commit a5f26c3 into main Jun 10, 2026
27 checks passed
@MathurAditya724 MathurAditya724 deleted the issue-1068-migrate-sentry-api-sdk-types branch June 10, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jared Trigger the Jared agent to work on stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: fully migrate to @sentry/api SDK types (remove all as-unknown-as casts)

1 participant