-
-
Notifications
You must be signed in to change notification settings - Fork 4k
types: allow calling create() with TRawDocType for better generics support #15903
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
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.
Pull request overview
This PR enhances TypeScript generics support for the create() method by adding direct overloads that accept TRawDocType, bypassing complex mapped types that can confuse TypeScript's assignability checking. This specifically addresses issue #15902 where generic type parameters couldn't be proven assignable to DeepPartial<ApplyBasicCreateCasting<Require_id<TRawDocType>>>.
Key Changes:
- Added two new
create()overloads acceptingTRawDocTypedirectly (single doc and array) - Added type test demonstrating the fix for generic wrapper classes
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| types/models.d.ts | Added two new create() overloads for TRawDocType (single and array) to support better generic type inference |
| test/types/create.test.ts | Added type test with generic class wrapper to verify the fix works for issue #15902 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…nts parent is the cloned document Fix #15902
AbdelrahmanHafez
left a comment
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.
Fix #15902
Summary
Applying mapping types like
ApplyBasicCreateCastingtend to confuse TypeScript about assignability:Kwon't necessarily be assignable toApplyBasicQueryCasting<Require_id<TRawDocType>>. Easiest fix is to add an override which allows passing partial ofTRawDocTypeto avoid generics headache.Examples