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

Add inferRawDocType helper #13900

Open
wants to merge 6 commits into
base: 8.4
Choose a base branch
from
Open

Add inferRawDocType helper #13900

wants to merge 6 commits into from

Conversation

vkarpov15
Copy link
Collaborator

Summary

As a potential workaround for #13772, this PR adds an inferRawDocType helper analogous to inferSchemaType (and mostly a copy of inferschematype.d.ts) to make it easier to automatically infer the raw doc type from the schema definition. This would also help with #13523. With this change, you can overwrite lean<> result types, etc.

Not ideal, but at least provides a workaround to more easily infer the correct raw doc type from the schema definition.

Examples

@vkarpov15
Copy link
Collaborator Author

Related issues: #12030

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.

do i understand correctly that this type is for getting a POJO type from a schema definition type?

i dont really like to have to repeat similar code, but i guess this is necessary.

though is it really required that we re-define exact helper functions that (at least look to me) to be the same as in inferschematype?

@vkarpov15
Copy link
Collaborator Author

A lot of the helper types are identical, I will see if there's some way to fix that.

The reason why we need a similar helper function is because of how InferSchemaType is structured, there's no way to pass a UseHydratedDocument switch to InferSchemaType. The problem right now is that InferSchemaType doesn't quite return the fully hydrated document type or the raw document type, but something in-between. inferRawDocType is an attempt to return the raw doc type, which I think is a good first step in the right direction. We've tried some alternative approaches, like #13856, but it's proving tricky to work around the inherent restrictions with InferSchemaType.

@vkarpov15
Copy link
Collaborator Author

@hasezoey I found a way to reuse the helpers from inferschematypes 👍

@JavaScriptBach
Copy link
Contributor

Isn't this just ObtainDocumentType? Or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants