[PR #5463] [MERGED] refactor: improve type in beforeHook #14267

Closed
opened 2026-04-13 09:23:10 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5463
Author: @bytaesu
Created: 10/21/2025
Status: Merged
Merged: 10/22/2025
Merged by: @himself65

Base: canaryHead: 2025-10-22/refactor/improve-beforehook-type


📝 Commits (1)

  • 36cd6a7 refactor: improve type in beforeHook

📊 Changes

1 file changed (+4 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/api/to-auth-endpoints.ts (+4 -6)

📄 Description

This PR improves the type inside beforeHook. I think it’s more appropriate for the modifiedContext variable to be part of InternalContext rather than just an object containing headers.


Summary by cubic

Switch modifiedContext to Partial in beforeHook processing to improve type safety and let hooks modify more context fields, not just headers. Existing headers merge behavior remains unchanged.

  • Refactors
    • Update modifiedContext type to Partial in runBeforeHooks.
    • Cast result.context as Partial during destructuring.
    • Keep headers merging logic intact.

🔄 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/5463 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 10/21/2025 **Status:** ✅ Merged **Merged:** 10/22/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2025-10-22/refactor/improve-beforehook-type` --- ### 📝 Commits (1) - [`36cd6a7`](https://github.com/better-auth/better-auth/commit/36cd6a740ed7c5c9254e23a8a9c4fc89b3a27891) refactor: improve type in beforeHook ### 📊 Changes **1 file changed** (+4 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/to-auth-endpoints.ts` (+4 -6) </details> ### 📄 Description This PR improves the type inside beforeHook. I think it’s more appropriate for the `modifiedContext` variable to be part of `InternalContext` rather than just an object containing headers. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Switch modifiedContext to Partial<InternalContext> in beforeHook processing to improve type safety and let hooks modify more context fields, not just headers. Existing headers merge behavior remains unchanged. - **Refactors** - Update modifiedContext type to Partial<InternalContext> in runBeforeHooks. - Cast result.context as Partial<InternalContext> during destructuring. - Keep headers merging logic intact. <!-- 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-13 09:23:10 -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#14267