Typescript additional fields date type error

Jumping straight to example: Add additional fields in the db schema and in the auth config user: { additionalFields: { birthday: { type: 'string', default: null }, dob: { type: 'date', default: null }, }, }, Expected behavior await updateUser({ birthday: values.birthday?.toISOString(), dob: values.birthday && values.birthday, }) Error I'm getting: Type 'Date | undefined' is not assignable to type 'undefined'. (dob field) It is reading date types as undefined in better-auth This error only occurs with type date, any other type in better-auth config is read correctly
2 Replies
bekacru
bekacru3mo ago
Please open a GitHub issue for this. The client doesn't properly handle serializing dates, which is why we left it as undefined for the time being. However, we should support it.
Kazz
KazzOP3mo ago
GitHub
Typescript additional fields date type error · Issue #705 · better-...
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 Add additional fie...

Did you find this page helpful?