docs: de-emphasize InferSchemaType<>
in TypeScript docs in favor of automatic inference
#14542
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.
Re: #14286
Summary
Did a bunch of work on the TypeScript docs to make it more clear that using
InferSchemaType<>
is usually not necessary. BecauseInferSchemaType<>
returns a mostly raw document interface but with DocumentArrays and Subdocs, it typically isn't useful for end users because you end up with a mostly-lean document.InferSchemaType<>
is still useful internally because it helps automatic type inference internally, but it unfortunately tries to satisfy both the lean document type and the hydrated document type, which leads to confusion.For user-facing API, we should instead encourage
inferRawDocType
from #13900, which will infer the raw doc type from the schema, andinferHydratedDocumentType
, which will infer the fully hydrated document type but is not yet written.Examples