Skip to content

feat: improve TypeScript type coverage across public SDK APIs - #416

Merged
Lakes41 merged 3 commits into
Adamantine-guild:mainfrom
spartan124:feat/issue-350-improve-ts-coverage
Jul 28, 2026
Merged

feat: improve TypeScript type coverage across public SDK APIs#416
Lakes41 merged 3 commits into
Adamantine-guild:mainfrom
spartan124:feat/issue-350-improve-ts-coverage

Conversation

@spartan124

Copy link
Copy Markdown
Contributor

Improve TypeScript type coverage across public SDK APIs (Resolves #350)

Description

This PR improves the overall developer experience and type safety of the GuildPass SDK by expanding TypeScript coverage and eliminating loosely typed structures across public APIs.

Historically, certain APIs and cached factory wrappers resulted in generic Promise<any> responses, reducing editor autocompletion and compile-time confidence. With these updates, generic inference correctly propagates through the SDK, especially around our advanced includeMeta request options.

What changed?

  • Strongly Typed Cache Factory: Refactored the GuildPassClient cached method factories (e.g. getMembership, getRoles, hasRole) to accurately infer return types using the O extends RequestOptions & { includeMeta?: boolean } generic pattern.
  • Removed Loose Dictionary Types: Replaced Record<string, any> usage in ContractClient.getCircuitBreakerSnapshot with the strongly-typed UrlHealth interface.
  • Improved Type Inference for HTTP Client: Default generic inference applied to HttpClient.get() and HttpClient.post() to cleanly map response types based on whether includeMeta is toggled.
  • Exported Reused SDK Types: Explicitly exported PaginatedResult and UrlHealth from src/types/index.ts so developers don't have to define ad-hoc interfaces.
  • Eliminated Unsafe any Casting: Removed unsafe any casts in AccessService in favor of precise type assertions leveraging SignedEnvelope<AccessCheckResult>.
  • Type-Level Tests: Introduced tests/type-coverage.test.ts to assert against expected API return types using expectTypeOf from vitest.

Acceptance Criteria

  • Public APIs expose strongly typed interfaces
  • Generic inference is improved (especially for .withCache methods)
  • Existing consumers remain compatible (no breaking changes)
  • Type tests verify exported APIs
  • Documentation perfectly reflects the existing typings

Type of change

  • Refactor (non-breaking change which improves code quality and type safety)

How to test

Review the new tests in tests/type-coverage.test.ts. Alternatively, running npm run typecheck validates that the entire SDK aligns correctly without compiler warnings (after resolving TS2209 configuration). Consumers of the SDK will immediately see more accurate types in their IDE for cached calls on client.membership, client.access, and client.roles.

@Lakes41

Lakes41 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Do resolve workflow conflicts @spartan124

@Lakes41
Lakes41 enabled auto-merge (squash) July 28, 2026 18:51
@Lakes41
Lakes41 disabled auto-merge July 28, 2026 18:51
@Lakes41
Lakes41 merged commit e2cca1a into Adamantine-guild:main Jul 28, 2026
2 checks passed
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.

Improve TypeScript type coverage across public SDK APIs

2 participants