diff --git a/test/types/schema.test.ts b/test/types/schema.test.ts index 0d737410ab2..b372d25cc79 100644 --- a/test/types/schema.test.ts +++ b/test/types/schema.test.ts @@ -1,5 +1,5 @@ import { Schema, Document, SchemaDefinition, Model, Types, InferSchemaType, SchemaType, Query } from 'mongoose'; -import { expectType, expectError, expectAssignable, expectNotAssignable } from 'tsd'; +import { expectType, expectError, expectAssignable } from 'tsd'; enum Genre { Action, @@ -439,19 +439,19 @@ export function autoTypedSchema() { }, { statics: { staticFn() { - expectAssignable>(this); + expectType>(this); return 'Returned from staticFn' as const; } }, methods: { instanceFn() { - expectAssignable(this); + expectAssignable>(this); return 'Returned from DocumentInstanceFn' as const; } }, query: { byUserName(userName) { - expectAssignable>(this); + expectAssignable>(this); return this.where({ userName }); } } diff --git a/types/index.d.ts b/types/index.d.ts index 0d5bec8fd6c..7674b260270 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -766,7 +766,7 @@ declare module 'mongoose' { /** * Create a new schema */ - constructor(definition?: SchemaDefinition> | DocType, options?: SchemaOptions); + constructor(definition?: SchemaDefinition> | DocType, options?: SchemaOptions); /** Adds key path / schema type pairs to this schema. */ add(obj: SchemaDefinition> | Schema, prefix?: string): this; diff --git a/types/schemaoptions.d.ts b/types/schemaoptions.d.ts index ad942be0e97..d33f628dc35 100644 --- a/types/schemaoptions.d.ts +++ b/types/schemaoptions.d.ts @@ -11,7 +11,7 @@ declare module 'mongoose' { type TypeKeyBaseType = string; type DefaultTypeKey = 'type'; - interface SchemaOptions { + interface SchemaOptions { /** * By default, Mongoose's init() function creates all the indexes defined in your model's schema by * calling Model.createIndexes() after you successfully connect to MongoDB. If you want to disable @@ -192,16 +192,16 @@ declare module 'mongoose' { /** * Model Statics methods. */ - statics?: Record>(this: T, ...args: any) => unknown> | StaticMethods, + statics?: Record>(this: T, ...args: any) => unknown> | StaticMethods, /** * Document instance methods. */ - methods?: Record(this: T, ...args: any) => unknown> | InstanceMethods, + methods?: Record>(this: T, ...args: any) => unknown> | InstanceMethods, /** * Query helper functions */ - query?: Record>(this: T, ...args: any) => T> | QueryHelpers, + query?: Record>(this: T, ...args: any) => T> | QueryHelpers, } } \ No newline at end of file