Skip to content

Commit

Permalink
fix(types): remove discriminator type requirement
Browse files Browse the repository at this point in the history
Since Model enforces Document when needed,
the discriminator type parameter don't need to extend it
  • Loading branch information
DouglasGabr committed Jul 15, 2021
1 parent 6250841 commit 982a389
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,8 @@ declare module 'mongoose' {

interface AcceptsDiscriminator {
/** Adds a discriminator type. */
discriminator<D extends Document>(name: string | number, schema: Schema<D>, value?: string | number | ObjectId): Model<D>;
discriminator<T extends Document, U extends Model<T>>(name: string | number, schema: Schema<T, U>, value?: string | number | ObjectId): U;
discriminator<D>(name: string | number, schema: Schema<D>, value?: string | number | ObjectId): Model<D>;
discriminator<T, U extends Model<T>>(name: string | number, schema: Schema<T, U>, value?: string | number | ObjectId): U;
}

interface AnyObject { [k: string]: any }
Expand Down Expand Up @@ -1703,8 +1703,8 @@ declare module 'mongoose' {

static options: { castNonArrays: boolean; };

discriminator<D extends Document>(name: string | number, schema: Schema<D>, value?: string): Model<D>;
discriminator<T extends Document, U extends Model<T>>(name: string | number, schema: Schema<T, U>, value?: string): U;
discriminator<D>(name: string | number, schema: Schema<D>, value?: string): Model<D>;
discriminator<T, U extends Model<T>>(name: string | number, schema: Schema<T, U>, value?: string): U;

/**
* Adds an enum validator if this is an array of strings or numbers. Equivalent to
Expand Down Expand Up @@ -1760,8 +1760,8 @@ declare module 'mongoose' {

static options: { castNonArrays: boolean; };

discriminator<D extends Document>(name: string | number, schema: Schema<D>, value?: string): Model<D>;
discriminator<T extends Document, U extends Model<T>>(name: string | number, schema: Schema<T, U>, value?: string): U;
discriminator<D>(name: string | number, schema: Schema<D>, value?: string): Model<D>;
discriminator<T, U extends Model<T>>(name: string | number, schema: Schema<T, U>, value?: string): U;

/** The schema used for documents in this array */
schema: Schema;
Expand Down

0 comments on commit 982a389

Please sign in to comment.