diff --git a/src/templates/core/CancelablePromise.hbs b/src/templates/core/CancelablePromise.hbs index 0480c9958..b7db949b8 100644 --- a/src/templates/core/CancelablePromise.hbs +++ b/src/templates/core/CancelablePromise.hbs @@ -49,7 +49,7 @@ export class CancelablePromise implements Promise { return; } this.#isResolved = true; - this.#resolve?.(value); + if (this.#resolve) this.#resolve(value); }; const onReject = (reason?: any): void => { @@ -57,7 +57,7 @@ export class CancelablePromise implements Promise { return; } this.#isRejected = true; - this.#reject?.(reason); + if (this.#reject) this.#reject(reason); }; const onCancel = (cancelHandler: () => void): void => { @@ -120,7 +120,7 @@ export class CancelablePromise implements Promise { } } this.#cancelHandlers.length = 0; - this.#reject?.(new CancelError('Request aborted')); + if (this.#reject) this.#reject(new CancelError('Request aborted')); } public get isCancelled(): boolean { diff --git a/test/__snapshots__/index.spec.ts.snap b/test/__snapshots__/index.spec.ts.snap index bbfc95cad..859a7af84 100644 --- a/test/__snapshots__/index.spec.ts.snap +++ b/test/__snapshots__/index.spec.ts.snap @@ -119,7 +119,7 @@ export class CancelablePromise implements Promise { return; } this.#isResolved = true; - this.#resolve?.(value); + if (this.#resolve) this.#resolve(value); }; const onReject = (reason?: any): void => { @@ -127,7 +127,7 @@ export class CancelablePromise implements Promise { return; } this.#isRejected = true; - this.#reject?.(reason); + if (this.#reject) this.#reject(reason); }; const onCancel = (cancelHandler: () => void): void => { @@ -3345,7 +3345,7 @@ export class CancelablePromise implements Promise { return; } this.#isResolved = true; - this.#resolve?.(value); + if (this.#resolve) this.#resolve(value); }; const onReject = (reason?: any): void => { @@ -3353,7 +3353,7 @@ export class CancelablePromise implements Promise { return; } this.#isRejected = true; - this.#reject?.(reason); + if (this.#reject) this.#reject(reason); }; const onCancel = (cancelHandler: () => void): void => {