[PR #7986] [MERGED] fix(client): infer additional fields for top-level user and session responses #24569

Closed
opened 2026-04-15 22:26:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7986
Author: @bytaesu
Created: 2/15/2026
Status: Merged
Merged: 2/16/2026
Merged by: @himself65

Base: canaryHead: 2026-02-16/fix/top-level-user-session-inference


📝 Commits (3)

  • 9a05b6f fix(client): infer additional fields for top-level user and session responses
  • eb9ca0a fix: refine user and session type inference for auth-like responses
  • 61bcf2c Merge branch 'canary' into 2026-02-16/fix/top-level-user-session-inference

📊 Changes

2 files changed (+69 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/client/path-to-object.ts (+35 -1)
📝 packages/better-auth/src/plugins/additional-fields/additional-fields.test.ts (+34 -0)

📄 Description

When a regression occurs, it results in a type check error in the test code rather than a test failure.


Summary by cubic

Fix type inference so top-level user and session in client responses include plugin-defined fields. Refinement only applies to auth-like responses (e.g., signIn) and keeps null/undefined (fixes #7982).

  • Bug Fixes
    • Added KeepNullishFromOriginal, ReplaceTopLevelField, ReplaceAuthUserAndSession, and RefineAuthResponse to refine top-level user/session while preserving null/undefined.
    • Updated InferRoute to use RefineAuthResponse so only auth-like responses (token or redirect) get refined types.
    • Added a React client test to assert signIn infers manual schema fields (role, optional phone) on user.

Written for commit 61bcf2cfa9. 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/7986 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 2/15/2026 **Status:** ✅ Merged **Merged:** 2/16/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-02-16/fix/top-level-user-session-inference` --- ### 📝 Commits (3) - [`9a05b6f`](https://github.com/better-auth/better-auth/commit/9a05b6f3d73e565e576236cca08717c153a6a9c8) fix(client): infer additional fields for top-level user and session responses - [`eb9ca0a`](https://github.com/better-auth/better-auth/commit/eb9ca0a92c14da212105b8be1e9bc5da36d09720) fix: refine user and session type inference for auth-like responses - [`61bcf2c`](https://github.com/better-auth/better-auth/commit/61bcf2cfa938b6b63fbf717545e3c9de2d6a0846) Merge branch 'canary' into 2026-02-16/fix/top-level-user-session-inference ### 📊 Changes **2 files changed** (+69 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/client/path-to-object.ts` (+35 -1) 📝 `packages/better-auth/src/plugins/additional-fields/additional-fields.test.ts` (+34 -0) </details> ### 📄 Description When a regression occurs, it results in a type check error in the test code rather than a test failure. - Closes #7982 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix type inference so top-level user and session in client responses include plugin-defined fields. Refinement only applies to auth-like responses (e.g., signIn) and keeps null/undefined (fixes #7982). - **Bug Fixes** - Added KeepNullishFromOriginal, ReplaceTopLevelField, ReplaceAuthUserAndSession, and RefineAuthResponse to refine top-level user/session while preserving null/undefined. - Updated InferRoute to use RefineAuthResponse so only auth-like responses (token or redirect) get refined types. - Added a React client test to assert signIn infers manual schema fields (role, optional phone) on user. <sup>Written for commit 61bcf2cfa938b6b63fbf717545e3c9de2d6a0846. 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:26:18 -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#24569