Repository navigation
fix(types): infer server user additionalFields in useSignUp - #836
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
better-auth | 94abeb3 | Commit Preview URL Branch Preview URL |
Dec 04 2026, 09:32 PM |
Latest result Pull request merged. Final answersSession Pull request merged. Session Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head. Session Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head. Session Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head. Session Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head. Session Updated the branch with main because main requires up-to-date branches; waiting for checks on the new head. PR #836 is ready to merge. I verified that the prior fix makes Nitro 2 shared projects infer required and optional sign-up fields while excluding fields marked `input: false`. The review thread is resolved, Pullfrog found no new issues, and all reported hosted checks, five focused tests, and `pnpm lint` passed. No further changes were needed. Fixed the reported P1: Nitro 2 shared projects now infer required and optional sign-up fields without enabling other server augmentations. All four focused tests and `pnpm lint` passed. Pushed `75ab7b2`, resolved the review thread, and am waiting for hosted checks. Session Waiting for review checks before the next pass. |
There was a problem hiding this comment.
Important
This PR does not provide server additionalFields inference for all supported server config shapes.
Approach: sound in principle — the generated server type is the right source for the email sign-up overlay, but the new augmentation is not available in every TypeScript program that consumes the composable.
Reviewed changes The generated AuthUserSignUpFields augmentation, the useSignUp('email') type overlay, and the plugin type-inference fixture were reviewed.
- Generated sign-up fields. Server
user.additionalFieldsare converted with Better Auth's client-input inference, preserving requiredness and excludinginput: falsefields. - Email sign-up typing. Only the
emailmethod is extended, andOmit<..., keyof Data>preserves fields already declared by the client method. - Regression coverage. The fixture checks required
tenantCode, optionalinternalCode, and rejection ofreadOnlyCode.
gpt-5.6-luna(high) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — the new commits separate sign-up field inference from the guarded server-only templates, allowing unsafe Nitro 2 configurations to expose the shared contract without sharing the rest of the server config graph.
Reviewed changes The incremental changes since the prior Pullfrog review were reviewed, including the shared-template registration and Nitro 2 alias fixture.
- Separated shared sign-up inference. Registered
AuthUserSignUpFieldsindependently in the shared type program while keeping the broader server inference templates behind their existing safety gate. - Added unsafe-config coverage. Added a
#serveranddbdependent Nitro 2 fixture that checks required and optional fields and rejectsinput: falsefields.
gpt-5.6-luna(high) | 𝕏

Fields from
user.additionalFieldsin the server config are missing fromuseSignUp('email'). Passing one fails to typecheck withTS2353 ... does not exist in type, even though Better Auth stores it at runtime.AuthUserandupdateUseralready include those fields, and plugin fields such asusernamealready show up in sign-up.useSignUptakes its types fromAppAuthClient, the return type of the client config. Better Auth only passes serveradditionalFieldsto the client when you addinferAdditionalFields<typeof auth>()to the client config, which means importing the server auth type into app code. The module already reads the server config for the user types, so sign-up should get those fields too.This PR generates an
AuthUserSignUpFieldstype from the server's input-enableduser.additionalFields, the same wayAuthUserUpdateInputis built.useSignUp('email')adds it to theemailinput. The fields keep therequiredsetting from the config, and fields withinput: falsestay out.AppAuthClientdoesn't change. If the client config already declares a field, the client's type wins. InclientOnlymode the type is empty.The
plugins-type-inferencefixture now has a requiredtenantCode. Onmainit fails withTS2353: 'tenantCode' does not exist, and it passes here. A missing required field and areadOnlyCodewithinput: falseboth fail to typecheck, as expected. Thetypesproject andpnpm typecheckpass. I didn't add a fixture for a client that already usesinferAdditionalFields().Fixes #831