Skip to content

Commit

Permalink
fix(index.d.ts): improve context and type bindings for `Schema#method…
Browse files Browse the repository at this point in the history
…s` and `Schema#statics`

Fix #9717
  • Loading branch information
vkarpov15 committed Jan 8, 2021
1 parent 8c17052 commit 1e79cac
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,11 @@ declare module 'mongoose' {

/** Adds an instance method to documents constructed from Models compiled from this schema. */
// eslint-disable-next-line @typescript-eslint/ban-types
method(name: string, fn: Function, opts?: any): this;
method(obj: { [name: string]: Function }): this;
method(name: string, fn: (this: DocType, ...args: any[]) => any, opts?: any): this;
method(obj: { [name: string]: (this: DocType, ...args: any[]) => any }): this;

/** Object of currently defined methods on this schema. */
methods: { [name: string]: (this: DocType, ...args: any[]) => void };
methods: { [F in keyof DocType]: DocType[F] } & { [name: string]: (this: DocType, ...args: any[]) => any };

/** The original object passed to the schema constructor */
obj: any;
Expand Down Expand Up @@ -1144,12 +1144,12 @@ declare module 'mongoose' {

/** Adds static "class" methods to Models compiled from this schema. */
// eslint-disable-next-line @typescript-eslint/ban-types
static(name: string, fn: Function): this;
static(name: string, fn: (this: M, ...args: any[]) => any): this;
// eslint-disable-next-line @typescript-eslint/ban-types
static(obj: { [name: string]: Function }): this;
static(obj: { [name: string]: (this: M, ...args: any[]) => any }): this;

/** Object of currently defined statics on this schema. */
statics: { [name: string]: Function };
statics: { [F in keyof M]: M[F] } & { [name: string]: (this: M, ...args: any[]) => any };

/** Creates a virtual type with the given name. */
virtual(name: string, options?: any): VirtualType;
Expand Down

0 comments on commit 1e79cac

Please sign in to comment.