From 52b85936cf3a4094f09b6f79df43626804e463c1 Mon Sep 17 00:00:00 2001 From: Stanimira Vlaeva Date: Wed, 10 Jul 2024 15:36:04 +0300 Subject: [PATCH 1/2] fix: declare dynamically assigned length property --- src/bulk/common.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bulk/common.ts b/src/bulk/common.ts index 892952c3cf..29370ff5c0 100644 --- a/src/bulk/common.ts +++ b/src/bulk/common.ts @@ -911,6 +911,8 @@ export class BulkWriteShimOperation extends AbstractOperation { /** @public */ export abstract class BulkOperationBase { isOrdered: boolean; + // Declare dynamically assigned property + declare length: number; /** @internal */ s: BulkOperationPrivate; operationId?: number; From 0301748a67ce5f07b4767209f50984fd2981be64 Mon Sep 17 00:00:00 2001 From: Stanimira Vlaeva Date: Thu, 11 Jul 2024 13:47:07 +0300 Subject: [PATCH 2/2] fix(NODE-6259): replace dynamic property assignment with a static getter --- src/bulk/common.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/bulk/common.ts b/src/bulk/common.ts index 29370ff5c0..ad0451e9ac 100644 --- a/src/bulk/common.ts +++ b/src/bulk/common.ts @@ -911,8 +911,6 @@ export class BulkWriteShimOperation extends AbstractOperation { /** @public */ export abstract class BulkOperationBase { isOrdered: boolean; - // Declare dynamically assigned property - declare length: number; /** @internal */ s: BulkOperationPrivate; operationId?: number; @@ -1180,6 +1178,10 @@ export abstract class BulkOperationBase { ); } + get length(): number { + return this.s.currentIndex; + } + get bsonOptions(): BSONSerializeOptions { return this.s.bsonOptions; } @@ -1276,13 +1278,6 @@ export abstract class BulkOperationBase { } } -Object.defineProperty(BulkOperationBase.prototype, 'length', { - enumerable: true, - get() { - return this.s.currentIndex; - } -}); - function isInsertBatch(batch: Batch): boolean { return batch.batchType === BatchType.INSERT; }