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 #11898

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions types/models.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
declare module 'mongoose' {
import mongodb = require('mongodb');

export interface AcceptsDiscriminator {
export interface AcceptsDiscriminator<B> {
/** Adds a discriminator type. */
discriminator<D>(name: string | number, schema: Schema, value?: string | number | ObjectId): Model<D>;
discriminator<D>(name: string | number, schema: Schema<D>, value?: string | number | ObjectId): Model<B & D>;
GCastilho marked this conversation as resolved.
Show resolved Hide resolved
discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string | number | ObjectId): U;
}

Expand Down Expand Up @@ -116,7 +116,7 @@ declare module 'mongoose' {
const Model: Model<any>;
interface Model<T, TQueryHelpers = {}, TMethodsAndOverrides = {}, TVirtuals = {}> extends
NodeJS.EventEmitter,
AcceptsDiscriminator,
AcceptsDiscriminator<T>,
IndexManager,
SessionStarter {
new <DocType = AnyKeys<T> & AnyObject>(doc?: DocType, fields?: any | null, options?: boolean | AnyObject): HydratedDocument<T, TMethodsAndOverrides, TVirtuals>;
Expand Down Expand Up @@ -416,4 +416,4 @@ declare module 'mongoose' {
where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(obj: object): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
}
}
}