-
Notifications
You must be signed in to change notification settings - Fork 61
Description
I have the following helper function:
export const getCurrentUser = async (
ctx: GenericQueryCtx<DataModel> | GenericMutationCtx<DataModel>,
auth: ReturnType<typeof createAuth>
): Promise<AuthDoc<"user">> => {
const session = await auth.api.getSession({
//baseURL: process.env.NEXT_PUBLIC_BASE_URL,
headers: await authComponent.getHeaders(ctx),
});
console.log("Session response:", session);
if (!session) {
throw new ConvexError("Not authenticated");
}
return session.user;
};
On the last line where session.user is returned I get an error: Type '{ id: string; createdAt: Date; updatedAt: Date; email: string; emailVerified: boolean; name: string; image?: string | null | undefined; username: string; onboardingStep?: number | null | undefined; ... 8 more ...; banExpires?: Date | ... 1 more ... | undefined; }' is missing the following properties from type '{ _id: Id<"user">; _creationTime: number; image?: string | null | undefined; userId?: string | null | undefined; role?: string | null | undefined; banned?: boolean | null | undefined; ... 12 more ...; username: string; }': _id, _creationTime ts(2739)
BetterAuth User type seems to lack _id and _creationTime fields.
By the way, I am using a local install of the BetterAuth Convex component. If I change the return type to:
Promise<
Omit<
AuthDoc<"user">,
"_id" | "_creationTime" | "createdAt" | "updatedAt" | "banExpires"
>
>
it gets rid of the type error. However, it does seem to defeat the purpose of the generated types in Convex.