BetterAuth User Type Safety
Any idea why the user returned from this function is of type "any"? Shouldn't it be typed according to the better auth user schema?
async getAuthUser(ctx: RunQueryCtx & { auth: ConvexAuth }) {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
return null;
}
const doc = await ctx.runQuery(this.component.lib.findOne, {
model: "user",
where: [
{
field: "userId",
value: identity.subject,
},
],
});
if (!doc) {
return null;
}
// Type narrowing
if (!("emailVerified" in doc)) {
throw new Error("invalid user");
}
const { id: _id, ...user } = doc;
return user;
}
1 Reply
Yeahhh me either