P
Prisma•3w ago
Crobatair

Broken JsDoc on prisma Upgrade from 4 to 5.22

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
}
@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"]>>>
{} 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
}
})
}
/**
* return all active posts
* @return {Promise<posts[]>}
*/
async fingAllActivePosts() {
return prisma.posts.findMany({
where: {
isActive: true
}
})
}
Thanks for the help 🥲
1 Reply
Nurul
Nurul•3w ago
Hi @Crobatair 👋 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. If it breaks starting from version 5.0.0 then it would imply that maybe some internal change we did could have triggered this.
Want results from more Discord servers?
Add your server