-
Notifications
You must be signed in to change notification settings - Fork 824
feat: mention PromiseReturnType alternative #6920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and con 8000 tact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Dangerous URL checkNo absolute URLs to prisma.io/docs found. |
Redirect checkThis PR probably requires the following redirects to be added to static/_redirects:
|
Deploying docs with
|
Latest commit: |
4b3a185
|
Status: | ✅ Deploy successful! |
Preview URL: | https://114a64b0.docs-51g.pages.dev |
Branch Preview URL: | https://da-3519.docs-51g.pages.dev |
...00-prisma-client/400-type-safety/100-operating-against-partial-structures-of-model-types.mdx
Outdated
Show resolved
Hide resolved
…g-against-partial-structures-of-model-types.mdx
...00-prisma-client/400-type-safety/100-operating-against-partial-structures-of-model-types.mdx
Outdated
Show resolved
Hide resolved
…g-against-partial-structures-of-model-types.mdx
You can use native the TypeScript utility type [`Awaited`](https://www.typescriptlang.org/docs/handbook/utility-types.html#awaitedtype) and [`ReturnType`](https://www.typescriptlang.org/docs/handbook/utility-types.html#returntypetype) to solve the problem elegantly: | ||
|
||
```ts | ||
type UsersWithPosts = Prisma.Awaited<ReturnType<typeof getUsersWithPosts>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Awaited
and not Prisma.Awaited
, it's a built-in type in TypeScript.
type UsersWithPosts = Prisma.Awaited<ReturnType<typeof getUsersWithPosts>> | ||
``` | ||
|
||
When using the `prisma-client-js` generator, a `PromiseReturnType` is exposed by the `Prisma` namespace, you can solve the problem using the `PromiseReturnType` type: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not convinced we still need to mention that PromiseReturnType
exists at all. I would just rewrite this section to use Awaited<ReturnType<typeof getUsersWithPosts>>
and that's it. Mentioning both seems redundant and potentially confusing for users to me.
No description provided.