diff --git a/test/types/schema.test.ts b/test/types/schema.test.ts index 66ed8ee28d9..e400dfa0ccf 100644 --- a/test/types/schema.test.ts +++ b/test/types/schema.test.ts @@ -570,9 +570,7 @@ export type AutoTypedSchemaType = { // discriminator const eventSchema = new Schema<{ message: string }>({ message: String }, { discriminatorKey: 'kind' }); const batchSchema = new Schema<{ name: string }>({ name: String }, { discriminatorKey: 'kind' }); -const discriminatedSchema = batchSchema.discriminator('event', eventSchema); - -expectType & { message: string }>>(discriminatedSchema); +batchSchema.discriminator('event', eventSchema); // discriminator statics const eventSchema2 = new Schema({ message: String }, { discriminatorKey: 'kind', statics: { static1: function() { @@ -581,9 +579,7 @@ const eventSchema2 = new Schema({ message: String }, { discriminatorKey: 'kind', const batchSchema2 = new Schema({ name: String }, { discriminatorKey: 'kind', statics: { static2: function() { return 1; } } }); -const discriminatedSchema2 = batchSchema2.discriminator('event', eventSchema2); - -expectAssignable & { message: string }, Model, {}, {}, {}, { static1(): number; static2(): number; }>>(discriminatedSchema2); +batchSchema2.discriminator('event', eventSchema2); function gh11828() { interface IUser { diff --git a/types/index.d.ts b/types/index.d.ts index ba560b634dd..5fc0853987b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -208,7 +208,7 @@ declare module 'mongoose' { /** Returns a copy of this schema */ clone(): T; - discriminator(name: string, schema: DisSchema): DiscriminatorSchema; + discriminator(name: string, schema: DisSchema): this; /** Returns a new schema that has the picked `paths` from this schema. */ pick(paths: string[], options?: SchemaOptions): T;