mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-09-25 02:20:25 +00:00
[mongoose] fixes lean return type (#40335)
* [mongoose] fixes lean return type commit https://github.com/DefinitelyTyped/DefinitelyTyped/commit/c74f860f8b80bb5542fbdafa0a81e260f2fec147#diff-ec6e6a45ee09ed93f5d81cb304c5a0b3 introduced typings for lean (instead of any). I like this approach, but it breaks old code, because type script assume T is undefined in this case. Also it didn't respect find or findOne and always used T directly. This approach fixes therefore two issues: - by default (if no type is provided), it is any again (backswards compatiblity) - Depending on the used functino it either returns the given type or an array of the given type. * fix(lean): it can also return null
This commit is contained in:
committed by
Pranav Senthilnathan
parent
412f9a452a
commit
e45aed2f51
Vendored
+1
-1
@@ -2000,7 +2000,7 @@ declare module "mongoose" {
|
||||
* getters/setters or other Mongoose magic applied.
|
||||
* @param {Boolean|Object} bool defaults to true
|
||||
*/
|
||||
lean<T>(bool?: boolean | object): Query<T> & QueryHelpers;
|
||||
lean<P = any>(bool?: boolean | object): Query<T extends Array<any> ? P[] : (P | null)> & QueryHelpers;
|
||||
|
||||
/** Specifies the maximum number of documents the query will return. Cannot be used with distinct() */
|
||||
limit(val: number): this;
|
||||
|
||||
Reference in New Issue
Block a user