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

fix(index.d.ts): improve typings for virtuals #10350

Merged
merged 1 commit into from
Jun 14, 2021
Merged

fix(index.d.ts): improve typings for virtuals #10350

merged 1 commit into from
Jun 14, 2021

Conversation

thiagokisaki
Copy link
Contributor

Summary
Created VirtualTypeOptions interface, improved VirtualType class and adjusted Schema methods related to virtuals.

Examples
I added a test file in test/typescript/virtuals.ts.

@thiagokisaki
Copy link
Contributor Author

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.

Thanks 👍

@vkarpov15 vkarpov15 changed the base branch from master to gh-10350 June 14, 2021 21:59
@vkarpov15 vkarpov15 merged commit b191d21 into Automattic:gh-10350 Jun 14, 2021
@vkarpov15 vkarpov15 added this to the 5.12.14 milestone Jun 14, 2021

/** Adds a custom getter to this virtual. */
// eslint-disable-next-line @typescript-eslint/ban-types
get(fn: Function): this;
get(fn: (this: D, value: any, virtual: this, doc: D) => any): this;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately I had to undo these changes. For some reason adding this generic param breaks defining new Schema() without a doc type and then using that schema for discriminator().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants