From 41e25b86e22a70f342a1cf42f91f957d9c2b14f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pit=20M=C3=BCller?= Date: Wed, 5 Jul 2023 14:26:47 +0200 Subject: [PATCH 1/2] fix: adjust promise resolve for next issue --- package-lock.json | 4 ++-- src/templates/core/CancelablePromise.hbs | 4 ++-- test/__snapshots__/index.spec.ts.snap | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 94c1b2b5..2c9cd1df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "openapi-typescript-codegen", - "version": "0.24.0", + "version": "0.25.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "openapi-typescript-codegen", - "version": "0.24.0", + "version": "0.25.0", "license": "MIT", "dependencies": { "camelcase": "^6.3.0", diff --git a/src/templates/core/CancelablePromise.hbs b/src/templates/core/CancelablePromise.hbs index 0480c995..e5c7f0d6 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 => { diff --git a/test/__snapshots__/index.spec.ts.snap b/test/__snapshots__/index.spec.ts.snap index bbfc95ca..859a7af8 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 => { From 11f84f51ed4f045a0cf1cf1ad8b7287ecd79619a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pit=20M=C3=BCller?= Date: Fri, 14 Jul 2023 08:36:47 +0200 Subject: [PATCH 2/2] fix: adjust additional intermediate value call --- src/templates/core/CancelablePromise.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/core/CancelablePromise.hbs b/src/templates/core/CancelablePromise.hbs index e5c7f0d6..b7db949b 100644 --- a/src/templates/core/CancelablePromise.hbs +++ b/src/templates/core/CancelablePromise.hbs @@ -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 {