diff --git a/index.d.ts b/index.d.ts index 34761907dc7..ed29d79d375 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1052,7 +1052,7 @@ declare module 'mongoose' { type SchemaPreOptions = { document?: boolean, query?: boolean }; type SchemaPostOptions = { document?: boolean, query?: boolean }; - class Schema = Model, SchemaDefinitionType = undefined> extends events.EventEmitter { + class Schema = Model, SchemaDefinitionType = undefined> extends events.EventEmitter { /** * Create a new schema */ diff --git a/test/typescript/models.ts b/test/typescript/models.ts index c65402c7829..b6917f876e8 100644 --- a/test/typescript/models.ts +++ b/test/typescript/models.ts @@ -1,4 +1,4 @@ -import { Schema, Document, Model, connection } from 'mongoose'; +import { Schema, Document, Model, connection, model } from 'mongoose'; function conventionalSyntax(): void { interface ITest extends Document { @@ -49,6 +49,21 @@ function insertManyTest() { }); } +function schemaStaticsWithoutGenerics() { + const UserSchema = new Schema({}); + UserSchema.statics.static1 = function() { return ''; }; + + interface IUserDocument extends Document { + instanceField: string; + } + interface IUserModel extends Model { + static1: () => string; + } + + const UserModel: IUserModel = model('User', UserSchema); + UserModel.static1(); +} + const ExpiresSchema = new Schema({ ttl: { type: Date,