DEV Community

Discussion on: Starting a Prisma + TypeScript Project

Collapse
 
2color profile image
Daniel Norman

Great article Sabin!

One thing to note is that you don't need to explicilty define the type for queries as its inferred:

    // Insteaf of this
    const users: User[] = await prisma.user.findMany();
    // users will have its type inferred.
    const users = await prisma.user.findMany();
Enter fullscreen mode Exit fullscreen mode

This also works in combination with include so if you fetch a relation the return type will automatically include the relation type too.

Collapse
 
sabinthedev profile image
Sabin Adams • Edited

Thanks for the advice! I'd added that Typing there primarily to demonstrate the fact that Prisma generated a User type for us, but you are absolutely right and I didn't make that clear!