Skip to content

Commit

Permalink
fix(index.d.ts): Fix return type of Model#aggregate()
Browse files Browse the repository at this point in the history
Type 'Promise<unknown>' is not assignable to type 'Promise<Document>'.
  • Loading branch information
orgads committed Dec 8, 2020
1 parent 0e2058d commit 067e3a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Expand Up @@ -578,8 +578,8 @@ declare module "mongoose" {
interface Model<T extends Document> extends NodeJS.EventEmitter {
new(doc?: any): T;

aggregate<R>(pipeline?: any[]): Aggregate<Array<R>>;
aggregate<R>(pipeline: any[], cb: Function): Promise<Array<R>>;
aggregate<R = any>(pipeline?: any[]): Aggregate<Array<R>>;
aggregate<R = any>(pipeline: any[], cb: Function): Promise<Array<R>>;

/** Base Mongoose instance the model uses. */
base: typeof mongoose;
Expand Down
2 changes: 2 additions & 0 deletions test/typescript/models.ts
Expand Up @@ -21,3 +21,5 @@ const ExpiresSchema = new Schema({
expires: 3600,
},
});

const aggregated: Promise<Document> = Test.aggregate([]).then(res => res[0]);

0 comments on commit 067e3a2

Please sign in to comment.