feat: remove 25 response-type as unknown as casts from API layer#1090
Merged
Conversation
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
Contributor
|
Contributor
Codecov Results 📊❌ Patch coverage is 76.92%. Project has 5015 uncovered lines. Files with missing lines (3)
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 |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 of #1068 — eliminates all response-type
as unknown ascasts fromsrc/lib/api/by wideningunwrapResult<T>andunwrapPaginatedResult<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 singledata as Tcast ininfrastructure.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:
result ascasts atunwrapPaginatedResultcall sitesdata.event as unknown as SentryEventto a singleas SentryEventinresolveEventInOrgTesting
tsc --noEmitpasses (only pre-existing errors from missing generated files).biome checkpasses clean.Closes #1068