Incorrect type inference with additionalFields inside a monorepo
I am using BetterAuth inside the
According to the BetterAuth documentation, the
This does not include the additional fields I defined in
packages
directory of my Turborepo.According to the BetterAuth documentation, the
Session
type should be inferred correctly using typeof auth.$Infer.Session
. However, when I hover over User
, I get the following inferred type:This does not include the additional fields I defined in
user.additionalFields
. Am I missing a step to ensure the custom fields are included in the inferred type?TypeScript | Better Auth
Better Auth TypeScript integration.
2 Replies
+1 I added a
role
additional field to the user it's not reflecting on types. Would be great to know how to fix it or if we're missing something.Ok, so this is what I was missing. Adding the
inferAdditionalFields
plugin to the client!
https://www.better-auth.com/docs/concepts/typescript#inferring-additional-fields-on-clientTypeScript | Better Auth
Better Auth TypeScript integration.