8000 feat: mention PromiseReturnType alternative by ankur-arch · Pull Request #6920 · prisma/docs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
May 21, 2025
Merged

feat: mention PromiseReturnType alternative #6920

merged 3 commits into from
May 21, 2025

Conversation

ankur-arch
Copy link
Contributor

No description provided.

@ankur-arch ankur-arch requested a review from nikolasburk May 21, 2025 10:02
Copy link
Contributor

Dangerous URL check

No absolute URLs to prisma.io/docs found.
No local URLs found.

Copy link
Contributor

Redirect check

This PR probably requires the following redirects to be added to static/_redirects:

  • This PR does not change any pages in a way that would require a redirect.

@ankur-arch ankur-arch self-assigned this May 21, 2025
Copy link
cloudflare-workers-and-pages bot commented May 21, 2025

Deploying docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4b3a185
Status: ✅  Deploy successful!
Preview URL: https://114a64b0.docs-51g.pages.dev
Branch Preview URL: https://da-3519.docs-51g.pages.dev

View logs

…g-against-partial-structures-of-model-types.mdx
…g-against-partial-structures-of-model-types.mdx
@ankur-arch ankur-arch merged commit a0900de into main May 21, 2025
8 of 9 checks passed
@ankur-arch ankur-arch deleted the DA-3519 branch May 21, 2025 11:02
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>>
Copy link
Member

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:
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0