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
Feature/enhance auto typed virtuals #12702
Conversation
- enables virtual types on all model methods
- virtuals themselves do not have virtuals available
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 🙂 |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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.
Thanks for the response and thanks for the fix, makes sense 🙂 |
fix(types): infer virtuals in query results
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