types: allow calling create() with TRawDocType for better generics support#15903
Merged
types: allow calling create() with TRawDocType for better generics support#15903
Conversation
Contributor
There was a problem hiding this comment.
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
approved these changes
Dec 18, 2025
hasezoey
approved these changes
Dec 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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