[GH-ISSUE #705] Typescript additional fields date type error #25710

Closed
opened 2026-04-17 15:58:39 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @Kazizodev on GitHub (Nov 30, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/705

Describe the bug
Date types in the Typescript additional fields is not implemented correctly for handling dates.
https://www.better-auth.com/docs/concepts/typescript

To Reproduce

  1. Add additional fields in the db schema and in the auth config
user: {
        additionalFields: {
            birthday: { type: 'string', default: null },
            dob: { type: 'date', default: null },
        },
    },
  1. Try to update the user
await updateUser({
       birthday: values.birthday?.toISOString(),
        dob: values.birthday && values.birthday, 
})
  1. Get Typescript error: "Type 'Date | undefined' is not assignable to type 'undefined'. (dob field)"

Expected behavior
It should take date values correctly. However, It is reading date types as undefined in better-auth

Additional context
This error only occurs with type date, any other type in better-auth config is read correctly

Originally created by @Kazizodev on GitHub (Nov 30, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/705 **Describe the bug** Date types in the Typescript additional fields is not implemented correctly for handling dates. https://www.better-auth.com/docs/concepts/typescript **To Reproduce** 1. Add additional fields in the db schema and in the auth config ``` user: { additionalFields: { birthday: { type: 'string', default: null }, dob: { type: 'date', default: null }, }, }, ``` 2. Try to update the user ``` await updateUser({ birthday: values.birthday?.toISOString(), dob: values.birthday && values.birthday, }) ``` 3. Get Typescript error: "Type 'Date | undefined' is not assignable to type 'undefined'. (dob field)" **Expected behavior** It should take date values correctly. However, It is reading date types as undefined in better-auth **Additional context** This error only occurs with type date, any other type in better-auth config is read correctly
GiteaMirror added the locked label 2026-04-17 15:58:39 -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#25710