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

Feature/enhance auto typed virtuals #12702

Conversation

carlosingles
Copy link

Summary

Further enhances existing virtual type inference originally from: #11908

Virtual properties are not available on model methods such as findOne, this PR adds that functionality across all model methods.

Also resolves: #12684

@carlosingles
Copy link
Author

apologies for the ping, but i updated the branch to fix the failing test. if there's any further feedback i'll get to it right away 🙂

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

We've confirmed that the reported issue is a bug, but there are some test failures and some issues with the test. In general, I'd like to avoid changing TypeScript tests to make them pass, because that may be hiding breaking changes.

We'll take a look and see if there's an alternative fix we can come up with.

if (doc) {
expectType<string>(doc.domain);
const json = doc.toJSON();
expectType<string>(json.domain);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is incorrect. domain shouldn't be in json unless you have toJSON: { virtuals: true } in your schema or globally.

@vkarpov15
Copy link
Collaborator

I'll close this in favor of #12720 for now. We can re-open if it turns out that #12720 is incorrect.

@vkarpov15 vkarpov15 closed this Nov 26, 2022
@carlosingles
Copy link
Author

Thanks for the response and thanks for the fix, makes sense 🙂

vkarpov15 added a commit that referenced this pull request Nov 28, 2022
fix(types): infer virtuals in query results
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.

InferSchemaType does not infer types for virtual fields from schema
2 participants