mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[mongoose] fixes lean return type (#40335)
* [mongoose] fixes lean return type
commit c74f860f8b (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
2
types/mongoose/index.d.ts
vendored
2
types/mongoose/index.d.ts
vendored
@@ -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