-
Type: Improvement
-
Resolution: Works as Designed
-
Priority: Unknown
-
None
-
Affects Version/s: 4.4.1
-
Component/s: None
-
Labels:
-
Empty show more show less
-
Not Needed
The reason for this is when you write some generic code, e.g. something like
function findSomeThings<TSchema>(collection: Collection<TSchema>):Promise<TSchema> { const filter = {} as Filter<TSchema>; return collection.findOne(filter); }
the overload with Callback is picked. This might be unintuitive but it's because Filter overlaps with Callback as types as Filter can just be Partial<T> with equals Partial<any> = any in this code. Thus I suggest reordering those overloads. The other scenario seems unlikely to kick in, as something typed to Callback<WithId<T>> would still resolve to the right overload even if the Filter one comes first
- depends on
-
NODE-4096 Investigate NODE-4095 - TypeScript: wrong findOne overload often picked
- Closed