-
Notifications
You must be signed in to change notification settings - Fork 61
Description
When I create an organization using auth.api in the user onCreate trigger, I am getting the following TypeScript error:
Property 'id' does not exist on type '({ id: string; name: string; slug: string; createdAt: Date; logo?: string | null | undefined; metadata?: any; } & { metadata: Record<string, any> | undefined; members: ({ id: string; organizationId: string; userId: string; role: string; createdAt: Date; } | undefined)[]; }) | null'.
I must cast the return type to { id: string; name: string; slug: string; createdAt: Date; logo?: string | null | undefined; metadata?: any; }
to get rid of the Type error.
triggers: {
user: {
onCreate: async (ctx, user) => {
const auth = createAuth(ctx);
const authCtx = await auth.$context;
const { id: organizationId } = (await auth.api.createOrganization({
body: {
userId: user._id,
name: user.name,
slug: user.username,
},
}));
Is there better way to createOrganization here I'm not seeing? I couldn't figure out how to run the internalAdapter of the organization plugin, for example.