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

Open
opened 2026-04-15 22:43:02 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8734
Author: @sleepe229
Created: 3/22/2026
Status: 🔄 Open

Base: mainHead: canary


📝 Commits (1)

  • b463d59 fix(core): declare inherited APIError properties to fix TypeScript type resolution

📊 Changes

1 file changed (+8 additions, -0 deletions)

View changed files

📝 packages/core/src/error/index.ts (+8 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8734 **Author:** [@sleepe229](https://github.com/sleepe229) **Created:** 3/22/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `canary` --- ### 📝 Commits (1) - [`b463d59`](https://github.com/better-auth/better-auth/commit/b463d59d3cd19f39654e7a2debbce71f5ef564d6) fix(core): declare inherited APIError properties to fix TypeScript type resolution ### 📊 Changes **1 file changed** (+8 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/error/index.ts` (+8 -0) </details> ### 📄 Description 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. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:43:02 -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#25080