Skip to content

feat(pagination): export SdkResult type for consumer use#74

Merged
MathurAditya724 merged 2 commits into
mainfrom
feat/export-sdk-result-type
Jun 3, 2026
Merged

feat(pagination): export SdkResult type for consumer use#74
MathurAditya724 merged 2 commits into
mainfrom
feat/export-sdk-result-type

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What

Exports SdkResult<TData, TError> from sentry-pagination.ts (and the package root).

Previously it was a private type used only by the pagination helpers internally.

Why

Downstream consumers that call @sentry/api SDK functions need the result type to write tightly-typed unwrapping helpers. Without this export they fall back to result: any, which TypeScript trusts the generic T on even though the actual discriminated-union shape is never verified.

With SdkResult exported, consumers can write:

import type { SdkResult } from '@sentry/api';

private unwrapSdkResult<TData>(result: SdkResult<TData>, context: string): TData {
  if (result.error !== undefined) { ... }
  return result.data;
}

This is the immediate follow-up to getsentry/sentry-mcp#931, where unwrapSdkResult currently uses result: any.

Changes

  • lib/sentry-pagination.ts: add export to SdkResult
  • build.mjs: include SdkResult in the export type { ... } line appended to src/index.ts during build

No logic changes.


View Session in Sentry

sentry-junior Bot and others added 2 commits June 3, 2026 08:46
SdkResult was a private local type used only by the pagination helpers.
Exporting it lets downstream consumers (e.g. sentry-mcp) write
properly-typed result-unwrapping wrappers without falling back to `any`.

Co-authored-by: Miguel Betegon <miguel.betegon@sentry.io>
@betegon betegon marked this pull request as ready for review June 3, 2026 08:55
@betegon betegon requested a review from MathurAditya724 June 3, 2026 08:55
@MathurAditya724 MathurAditya724 merged commit 7822746 into main Jun 3, 2026
10 checks passed
@MathurAditya724 MathurAditya724 deleted the feat/export-sdk-result-type branch June 3, 2026 09:33
MathurAditya724 added a commit to getsentry/sentry-mcp that referenced this pull request Jun 3, 2026
Bump @sentry/api to ^0.172.0 which exports the SdkResult type from
getsentry/sentry-api-schema#74.

The SDK functions return RequestResult whose conditional generic
encoding (TData[keyof TData]) is not structurally assignable to
SdkResult, so unwrapSdkResult keeps `any` for the parameter type.
Updated the JSDoc to reference SdkResult as the runtime contract
and explain why the type mismatch exists.

Co-Authored-By: Claude (claude-opus-4-6)
dcramer pushed a commit to getsentry/sentry-mcp that referenced this pull request Jun 12, 2026
Bump @sentry/api to ^0.172.0 which exports the SdkResult type from
getsentry/sentry-api-schema#74.

The SDK functions return RequestResult whose conditional generic
encoding (TData[keyof TData]) is not structurally assignable to
SdkResult, so unwrapSdkResult keeps `any` for the parameter type.
Updated the JSDoc to reference SdkResult as the runtime contract
and explain why the type mismatch exists.

Co-Authored-By: Claude (claude-opus-4-6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants