From eee6dbb1a6e1ca0e3c6bfc25e93ff191205ff5cd Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Mon, 28 Aug 2023 19:41:28 +0300 Subject: [PATCH] remove unnecessary initialization of empty array --- src/execution/IncrementalPublisher.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/execution/IncrementalPublisher.ts b/src/execution/IncrementalPublisher.ts index d34ae102c2..f8ac936510 100644 --- a/src/execution/IncrementalPublisher.ts +++ b/src/execution/IncrementalPublisher.ts @@ -565,7 +565,9 @@ export class IncrementalPublisher { continue; } const incrementalResult: IncrementalStreamResult = { - items: subsequentResultRecord.items, + // safe because `items` is always defined when the record is completed + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + items: subsequentResultRecord.items!, // safe because `id` is defined once the stream has been released as pending // eslint-disable-next-line @typescript-eslint/no-non-null-assertion id: subsequentResultRecord.streamRecord.id!, @@ -624,6 +626,7 @@ export class IncrementalPublisher { ); const id = recordWithLongestPath.id; const incrementalDeferResult: IncrementalDeferResult = { + // safe because `data``is always defined when the record is completed // eslint-disable-next-line @typescript-eslint/no-non-null-assertion data: data!, // safe because `id` is defined once the fragment has been released as pending @@ -825,7 +828,7 @@ export class StreamItemsRecord { errors: Array; streamRecord: StreamRecord; path: ReadonlyArray; - items: Array; + items: Array | undefined; children: Set; isFinalRecord?: boolean; isCompletedAsyncIterator?: boolean; @@ -839,7 +842,6 @@ export class StreamItemsRecord { this.errors = []; this.isCompleted = false; this.filtered = false; - this.items = []; } }