Theo's Typesafe CultTTC
Theo's Typesafe Cult4y ago
4 replies
jix74

Anyone know how to fix this typescript issue?

I'm trying to connect taskId to an existing task table but I'm getting an error that says:
Type '{ connect: { id: string | undefined; }; }' is not assignable to type 'string'.ts(2322)

It is a one to many relationship (many tasks on a list).

const list = await createList();
//^^ this part creates a list via a transaction in a different file and returns the data

const task = await prisma.$transaction( Array(10) .fill(null) .map((_, i) => { return prisma.task.create({ data: { taskName: "Some name" taskDescription: "some description" listId: { <-HERE IS THE ISSUE (red squiggly) connect: { id: list[i]?.id, }, }, ....more queries & brackets, etc...
Was this page helpful?