Skip to content

types(inferrawdoctype): avoid adding _id to nested paths and handle _id: false in options + schema definition#15989

Open
vkarpov15 wants to merge 7 commits intomasterfrom
vkarpov15/gh-15988
Open

types(inferrawdoctype): avoid adding _id to nested paths and handle _id: false in options + schema definition#15989
vkarpov15 wants to merge 7 commits intomasterfrom
vkarpov15/gh-15988

Conversation

@vkarpov15
Copy link
Collaborator

Summary

InferRawDocType<> currently adds _id whenever the schema definition is a record, which means nested paths get _id. We also need to handle _id: false in the schema definition.

Examples

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ResolveRawPathType handling for record schema definitions to avoid adding _id for nested paths and to honor { _id: false }.
  • Update an existing type assertion in schema.create tests to reflect the new nested-path behavior.
  • Add new type tests covering nested paths vs subdocuments and _id: false subdocuments.

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.

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple of changes in #15994, otherwise LGTM 👍

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Jan 31, 2026
@vkarpov15 vkarpov15 modified the milestones: 9.1.6, 9.2 Feb 4, 2026
fix(types): support custom `typeKey` for subdoc type inference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript Types or Types-test related issue / Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants