From 1cdaa0a699da082c9fccc377e643c247556673ce Mon Sep 17 00:00:00 2001 From: Grimmer Date: Tue, 4 Jun 2019 07:30:55 +0800 Subject: [PATCH] Fix wrong type definition on lean function parameter (#35916) * Fix wrong type definition on lean function parameter * Update the parameter type in lean function --- types/mongoose/index.d.ts | 5 +++-- types/mongoose/mongoose-tests.ts | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 9f909c4695..9c003cb666 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -24,6 +24,7 @@ // Erik Lopez // Vlad Melnik // Jarom Loveridge +// Grimmer Kang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -1935,9 +1936,9 @@ declare module "mongoose" { * Documents returned from queries with the lean option enabled are plain * javascript objects, not MongooseDocuments. They have no save method, * getters/setters or other Mongoose magic applied. - * @param bool defaults to true + * @param {Boolean|Object} bool defaults to true */ - lean(bool?: boolean): Query & QueryHelpers; + lean(bool?: boolean | object): Query & QueryHelpers; /** Specifies the maximum number of documents the query will return. Cannot be used with distinct() */ limit(val: number): this; diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 55faba9f88..d3688747b0 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -1199,6 +1199,12 @@ query. sort('-occupation'). select('name occupation'). exec(cb).then(cb).catch(cb); +/** + * https://mongoosejs.com/docs/api.html#query_Query-lean + */ +query.lean() // true +query.lean(false) +query.lean({}) /* * section schema/array.js