#Broken JsDoc on prisma Upgrade from 4 to 5.22

2 messages · Page 1 of 1 (latest)

gentle hazel
#

I just upgraded the Prisma version from 4 to 5.22 and noticed that my IDE no longer recognizes some typedefs I was using.
I used to create a Typedef file to use the Prisma types in JSdoc.

  • Prisma version: 5.22
  • NodeJs 20
  • Prisma provider -> prisma-client-js
  • Previews -> prismaSchemaFolder

The import was the following:

@typedef {import('@prisma/client').posts } posts
@typedef {import('@prisma/client').PrismaClient['posts']} postsModel

/** @typedef posts */
let posts;

/** @typedef postsModel */
let postsModel;

module.exports = { 
  posts,
  postsModel
}

And by returning the methods with the JSdoc I could hover over the variables.
Now, the IDE shows the returned types as follows:

{} extends {omit: infer LocalOmit} ? ApplyOmit<UnwrapPayload<{default: Prisma.$postsPayload<$Extensions.DefaultArgs>}>["default"], PatchFlat<LocalOmit, ExtractGlobalOmit<{}, Uncapitalize<Prisma.$postsPayload<$Extensions.DefaultArgs>["name"]>>>> : ApplyOmit<UnwrapPayload<{default: Prisma.$postsPayload<$Extensions.DefaultArgs>}>["default"], ExtractGlobalOmit<{}, Uncapitalize<Prisma.$postsPayload<$Extensions.DefaultArgs>["name"]>>>

Is there a way to fix the jsdoc, and return the objects as:

/**
 * return all active posts
 * @return {Promise<posts[]>}
 */
async fingAllActivePosts() {
    return prisma.posts.findMany({
       where: {
           isActive: true
       }
    })
}

Thanks for the help 🥲

silk dragon
#

Hi @gentle hazel 👋

Can you try with prisma versions 4.16.2 and 5.0.0 and see if it is breaking for you starting from version 5.0.0?

I haven't encountered any open any GitHub Issues reporting this same behaviour.