diff --git a/test/types/queries.test.ts b/test/types/queries.test.ts index 23ae0424cb..3f22400fa6 100644 --- a/test/types/queries.test.ts +++ b/test/types/queries.test.ts @@ -863,5 +863,5 @@ async function gh15786() { } const schema = new Schema, {}, {}, {}, DocStatics>({}); - schema.static({ m1() {} } as DocStatics); + schema.static({ m1() {} }); } diff --git a/types/index.d.ts b/types/index.d.ts index a445427e4c..9f220e0c24 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -622,9 +622,8 @@ declare module 'mongoose' { set(key: K, value: SchemaOptions[K], _tags?: any): this; /** Adds static "class" methods to Models compiled from this schema. */ - static(name: K, fn: TStaticMethods[K]): this; - static(obj: { [F in keyof TStaticMethods]: TStaticMethods[F] }): this; - static(obj: { [F in keyof TStaticMethods]: TStaticMethods[F] } & { [name: string]: (this: TModelType, ...args: any[]) => any }): this; + static(name: K, fn: TStaticMethods[K] & ((this: TModelType, ...args: any[]) => any)): this; + static(obj: Partial & { [name: string]: (this: TModelType, ...args: any[]) => any }): this; static(name: string, fn: (this: TModelType, ...args: any[]) => any): this; /** Object of currently defined statics on this schema. */