types(inferrawdoctype): avoid adding _id to nested paths and handle _id: false in options + schema definition#15989
Open
types(inferrawdoctype): avoid adding _id to nested paths and handle _id: false in options + schema definition#15989
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates InferRawDocType<> typing logic so nested schema-definition objects don’t incorrectly get _id added, and so subdocument definitions with _id: false are respected.
Changes:
- Adjust
ResolveRawPathTypehandling for record schema definitions to avoid adding_idfor nested paths and to honor{ _id: false }. - Update an existing type assertion in
schema.createtests to reflect the new nested-path behavior. - Add new type tests covering nested paths vs subdocuments and
_id: falsesubdocuments.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| types/inferrawdoctype.d.ts | Changes record-path inference to avoid _id on nested paths and handle { _id: false }. |
| test/types/schema.create.test.ts | Updates expected inferred type for a nested-path case (no nested _id). |
| test/types/inferrawdoctype.test.ts | Adds new type-level coverage for nested paths vs subdocuments and _id: false. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AbdelrahmanHafez
requested changes
Jan 31, 2026
Collaborator
AbdelrahmanHafez
left a comment
There was a problem hiding this comment.
Added a couple of changes in #15994, otherwise LGTM 👍
hasezoey
approved these changes
Jan 31, 2026
fix(types): support custom `typeKey` for subdoc type inference
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.
Summary
InferRawDocType<>currently adds_idwhenever the schema definition is a record, which means nested paths get_id. We also need to handle_id: falsein the schema definition.Examples