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: Discriminator generic type not being passed to schema #11897

Closed
wants to merge 1 commit into from

Conversation

GCastilho
Copy link
Contributor

-- Fix schema type passed to discriminator method not extending Document

Summary

A model created from a discriminator does not have types for the "document" (save, find, etc) as the original model does

Examples

# Old
const ClickedLinkEvent = Event.discriminator('ClickedLink', new mongoose.Schema({ url: String }, options));
ClickedLinkEvent.save() // save has type any

# New
ClickedLinkEvent.save() // save has the type from Document['save']

@GCastilho GCastilho changed the title fix: Discriminator Schema not extending Document fix: Discriminator generic type not being passed to schema Jun 5, 2022
-- Fix the generic 'D' type of the discriminator not being passed to the schema, resulting in a property with type 'any'
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

1 participant