typing error with custom field

I’m getting a TypeScript typing issue where additionalFields become never or null | undefined in the signUpEmail body. This happens even with the example from the docs (lang field). config (in a separate package in a monorepo) :
export const auth = betterAuth({
// ...configs
user: {
additionalFields: {
lang: { // just like the docs
type: "string",
required: false,
defaultValue: "en",
}
},
},
});
export const auth = betterAuth({
// ...configs
user: {
additionalFields: {
lang: { // just like the docs
type: "string",
required: false,
defaultValue: "en",
}
},
},
});
Usage (in another package):
const { user: createdUser } = await auth.api.signUpEmail({
body: {
email: userData.email,
name: userData.name,
password: userData.password,
lang: 'pt-BR', // Type 'string' is not assignable to type 'null | undefined'.ts(2322)
},
});
const { user: createdUser } = await auth.api.signUpEmail({
body: {
email: userData.email,
name: userData.name,
password: userData.password,
lang: 'pt-BR', // Type 'string' is not assignable to type 'null | undefined'.ts(2322)
},
});
If I remove the default value from config, the type of the lang field in signUpEmail body changes to never and the error to "Type 'string' is not assignable to type 'never'.ts(2322)" (using fastify)
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?