-
-
Notifications
You must be signed in to change notification settings - Fork 111
fix: type error of Enhanced
helper
#2137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact 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
📝 WalkthroughWalkthroughThe change simplifies the generic parameter inference in the conditional type definition of the Changes
Possibly related PRs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/schema/src/plugins/enhancer/enhance/index.ts (1)
288-295
: Request: Add type-level tests & tighten first branch inference
The newEnhanced<Client>
alias now matches any_PrismaClient<any, any, any>
and only infersExtArgs
for dynamic clients via_Prisma.TypeMap<infer ExtArgs>
. To ensure no unintended types slip through and to catch regressions:
- Add a
tsd
(ordtslint
) test underpackages/schema
verifying:
Enhanced<typeof prisma>
strictly resolves toPrismaClient
.Enhanced<typeof extClient>
resolves to the correctDynamicClientExtensionThis<…>
shape.- Consider tightening the first branch from
any
tounknown
for stricter matching, e.g.:Client extends _PrismaClient<unknown, unknown, unknown> ? PrismaClient : …Example
tsd
snippet:import { expectType } from 'tsd'; import { PrismaClient } from '@prisma/client'; import { Enhanced } from '../src/plugins/enhancer/enhance'; declare const prisma: PrismaClient; expectType<PrismaClient>(null as any as Enhanced<typeof prisma>); // Simulated extended client import type { DynamicClientExtensionThis } from '@prisma/client/runtime/library'; type ExtArgs = { foo: string }; declare const extClient: DynamicClientExtensionThis<PrismaClient['_types']['Model'], any, ExtArgs>; expectType< DynamicClientExtensionThis<PrismaClient['_types']['Model'], any, ExtArgs> >(null as any as Enhanced<typeof extClient>);This will catch broken inferences in both branches.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/schema/src/plugins/enhancer/enhance/index.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: build-test (20.x)
- GitHub Check: OSSAR-Scan
- GitHub Check: build-test (20.x)
- GitHub Check: build-test (20.x)
- GitHub Check: dependency-review
No description provided.