-
Type: Improvement
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: 4.0.0
-
Component/s: Lambda
I just tried migrating our platform to the new beta MongoDB driver to see if everything still works fine and I had to manually cast a lot of things manually because the generic types are gone.
An example diff from our code base (before/after):
diff --git a/apps/lambda-kyc/src/entities/mentor-limitchange-stats.entity.ts b/apps/lambda-kyc/src/entities/mentor-limitchange-stats.entity.ts index 5e722dd8a..a2242b18c 100644 --- a/apps/lambda-kyc/src/entities/mentor-limitchange-stats.entity.ts +++ b/apps/lambda-kyc/src/entities/mentor-limitchange-stats.entity.ts @@ -32,7 +32,7 @@ export class MentorLimitChangeStats extends Entity { static async getAggregatedByHour(brandId: string, hour: number) { const db = Container.get(MongoClient); const mentorLimitChangeStatsCollection = await db.getCollection<MentorLimitChangeStats>(MentorLimitChangeStats.__name); - const hourAggregate = mentorLimitChangeStatsCollection.aggregate<{ _id: null; total: number }>([ + const hourAggregate = mentorLimitChangeStatsCollection.aggregate([ { $match: { brandId, @@ -48,7 +48,7 @@ export class MentorLimitChangeStats extends Entity { }, }, ]); - return hourAggregate.toArray(); + return hourAggregate.toArray() as Promise<Array<{ _id: null; total: number }>>; } async updateFromAggregateEvent<P extends EventPayload>(sourceEvent: AggregateEvent<P>) {
If you check the types from DefinitelyTyped for the current version you will see what I mean: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/mongodb/index.d.ts#L1236
- is duplicated by
-
NODE-3128 Much of the type safety from the 3.x driver is missing in the 4.x betas
- Closed