Skip to content
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

docs: de-emphasize InferSchemaType<> in TypeScript docs in favor of automatic inference #14542

Merged
merged 5 commits into from Apr 29, 2024

Conversation

vkarpov15
Copy link
Collaborator

Re: #14286

Summary

Did a bunch of work on the TypeScript docs to make it more clear that using InferSchemaType<> is usually not necessary. Because InferSchemaType<> 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, and inferHydratedDocumentType, which will infer the fully hydrated document type but is not yet written.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

Looks good, some suggestions if we touch that documentation

docs/typescript/schemas.md Outdated Show resolved Hide resolved
docs/typescript/schemas.md Outdated Show resolved Hide resolved
docs/typescript/schemas.md Outdated Show resolved Hide resolved
docs/typescript/schemas.md Outdated Show resolved Hide resolved
@hasezoey hasezoey added the docs This issue is due to a mistake or omission in the mongoosejs.com documentation label Apr 28, 2024
vkarpov15 and others added 4 commits April 29, 2024 15:30
Co-authored-by: hasezoey <hasezoey@gmail.com>
Co-authored-by: hasezoey <hasezoey@gmail.com>
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15 vkarpov15 merged commit 72da808 into master Apr 29, 2024
5 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-14286 branch April 30, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants