Skip to content

Commit

Permalink
Merge branch 'master' into gh-9850
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 authored Mar 3, 2021
2 parents 64739b5 + b23f4f1 commit 964dfd5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ declare module 'mongoose' {
type SchemaPreOptions = { document?: boolean, query?: boolean };
type SchemaPostOptions = { document?: boolean, query?: boolean };

class Schema<DocType extends Document = Document, M extends Model<DocType, any> = Model<DocType>, SchemaDefinitionType = undefined> extends events.EventEmitter {
class Schema<DocType extends Document = Document, M extends Model<DocType, any> = Model<any, any>, SchemaDefinitionType = undefined> extends events.EventEmitter {
/**
* Create a new schema
*/
Expand Down
17 changes: 16 additions & 1 deletion test/typescript/models.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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<IUserDocument> {
static1: () => string;
}

const UserModel: IUserModel = model<IUserDocument, IUserModel>('User', UserSchema);
UserModel.static1();
}

const ExpiresSchema = new Schema({
ttl: {
type: Date,
Expand Down

0 comments on commit 964dfd5

Please sign in to comment.