diff --git a/test/types/queries.test.ts b/test/types/queries.test.ts index 2f729f4e5c..16e85e5148 100644 --- a/test/types/queries.test.ts +++ b/test/types/queries.test.ts @@ -798,3 +798,17 @@ function gh15671() { }; }; } + +async function gh15786() { + interface IDoc { + nmae: string; + } + + interface DocStatics { + m1(): void; + m2(): void; + } + + const schema = new Schema, {}, {}, {}, DocStatics>({}); + schema.static({ m1() {} } as DocStatics); +} diff --git a/types/index.d.ts b/types/index.d.ts index 8e8b5ad67f..30fb89a9ab 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -542,6 +542,7 @@ declare module 'mongoose' { /** 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: string, fn: (this: TModelType, ...args: any[]) => any): this;