[PR #8734] fix(core): declare inherited APIError properties to fix TypeScript ty… #16426

Open
opened 2026-04-13 10:31:06 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8734

State: open
Merged: No


Fixes #8729

When APIError in @better-auth/core/error extends BaseAPIError from better-call/error,
TypeScript cannot resolve inherited instance properties (message, status, body, etc.)
because better-call exports APIError as a const (created via makeErrorForHideStackFrame)
rather than a proper class.

Added explicit declare property statements to APIError class — compile-time only,
no runtime overhead — so TypeScript correctly exposes these properties after isAPIError() narrowing.


Summary by cubic

Declare and type inherited APIError properties in @better-auth/core (status, body, headers, statusCode, message) so TypeScript exposes them after isAPIError() narrowing. Types-only change; no runtime impact.

Written for commit b463d59d3c. Summary will update on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8734 **State:** open **Merged:** No --- Fixes #8729 When `APIError` in `@better-auth/core/error` extends `BaseAPIError` from `better-call/error`, TypeScript cannot resolve inherited instance properties (`message`, `status`, `body`, etc.) because `better-call` exports `APIError` as a `const` (created via `makeErrorForHideStackFrame`) rather than a proper `class`. Added explicit `declare` property statements to `APIError` class — compile-time only, no runtime overhead — so TypeScript correctly exposes these properties after `isAPIError()` narrowing. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Declare and type inherited `APIError` properties in `@better-auth/core` (`status`, `body`, `headers`, `statusCode`, `message`) so TypeScript exposes them after `isAPIError()` narrowing. Types-only change; no runtime impact. <sup>Written for commit b463d59d3cd19f39654e7a2debbce71f5ef564d6. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 10:31:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16426