[TS Error] user.locale missing in Better Auth type after adding custom field
I added a custom locale field via additionalFields in Better Auth, but TypeScript still throws:
Property 'locale' does not exist on type '{ id: string; name: string; emailVerified: boolean; email: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; }'.ts(2339)
How do I properly type the custom locale field so it appears on the Better Auth User type?
6 Replies
did u inferred it to auth-client.ts file?
no i didnt, let me try it
thats why
sir
wait, but there is probably nothing in common, coz i am getting error in server auth.ts when i am trying to send an email
Ping
Yeah that's an issue with Better-auth where any
user
or session
or anything related to those type are not inferred within the auth config.
If you console.log the user you will likely see those fields, you can freely type assert to overwrite the types.Solution: