From 8feb1f8377f2524d6b9f36255887ba0def75338b Mon Sep 17 00:00:00 2001 From: Jehiah Czebotar Date: Fri, 7 Nov 2025 15:59:48 -0500 Subject: [PATCH 1/2] fix(typescript-fetch): ResponseError prototype chain --- .../typescript-fetch/runtime.mustache | 18 ++++++++++++++++++ .../tests/default/test/PetApi.ts | 9 ++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 8cfe7948e922..acd04c40d5eb 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -251,6 +251,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -258,6 +264,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -265,6 +277,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts index c452573699d5..adbbed1dd340 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/tests/default/test/PetApi.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { PetApi, Pet, PetStatusEnum, Category } from '@swagger/typescript-fetch-petstore'; +import { PetApi, Pet, PetStatusEnum, Category, ResponseError } from '@swagger/typescript-fetch-petstore'; import { config } from '../configuration'; describe('PetApi', () => { @@ -49,6 +49,13 @@ describe('PetApi', () => { }); }); + it('instanceof ResponseError not Error', () => { + const response = new Response(); + const err = new ResponseError(response, 'test error message'); + expect(err instanceof ResponseError).to.be.true; + expect(err instanceof Error).to.be.true; + }); + }); } From 5c5ead1d6f9f5559f4c7ebd93d4d019ef8a2e741 Mon Sep 17 00:00:00 2001 From: Jehiah Czebotar Date: Thu, 19 Feb 2026 10:17:16 -0500 Subject: [PATCH 2/2] samples/*/typescript-fetch: re-generate runtime.ts --- .../infinite-recursion-issue/runtime.ts | 18 ++++++++++++++++++ .../self-import-issue/runtime.ts | 18 ++++++++++++++++++ .../builds/allOf-nullable/runtime.ts | 18 ++++++++++++++++++ .../builds/allOf-readonly/runtime.ts | 18 ++++++++++++++++++ .../builds/default-v3.0/runtime.ts | 18 ++++++++++++++++++ .../typescript-fetch/builds/default/runtime.ts | 18 ++++++++++++++++++ .../typescript-fetch/builds/enum/runtime.ts | 18 ++++++++++++++++++ .../builds/es6-target/src/runtime.ts | 18 ++++++++++++++++++ .../builds/multiple-parameters/runtime.ts | 18 ++++++++++++++++++ .../typescript-fetch/builds/oneOf/runtime.ts | 18 ++++++++++++++++++ .../prefix-parameter-interfaces/src/runtime.ts | 18 ++++++++++++++++++ .../builds/sagas-and-records/src/runtime.ts | 18 ++++++++++++++++++ .../builds/snakecase-discriminator/runtime.ts | 18 ++++++++++++++++++ .../builds/validation-attributes/runtime.ts | 18 ++++++++++++++++++ .../builds/with-interfaces/runtime.ts | 18 ++++++++++++++++++ .../builds/with-npm-version/src/runtime.ts | 18 ++++++++++++++++++ .../builds/with-string-enums/runtime.ts | 18 ++++++++++++++++++ .../without-runtime-checks/src/runtime.ts | 18 ++++++++++++++++++ 18 files changed, 324 insertions(+) diff --git a/samples/client/others/typescript-fetch/infinite-recursion-issue/runtime.ts b/samples/client/others/typescript-fetch/infinite-recursion-issue/runtime.ts index 492083e7c372..f59a24beaf1c 100644 --- a/samples/client/others/typescript-fetch/infinite-recursion-issue/runtime.ts +++ b/samples/client/others/typescript-fetch/infinite-recursion-issue/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/others/typescript-fetch/self-import-issue/runtime.ts b/samples/client/others/typescript-fetch/self-import-issue/runtime.ts index c3175f3bac29..15e78cb9c282 100644 --- a/samples/client/others/typescript-fetch/self-import-issue/runtime.ts +++ b/samples/client/others/typescript-fetch/self-import-issue/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts index c9b10a3dc885..d14bf5837c37 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts index c9b10a3dc885..d14bf5837c37 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts index 6d3d965df11d..0296a2863f5b 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 3f125c3b0601..917967f1d078 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts index 8095de29bc32..c4c63d2df81f 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts index 3f125c3b0601..917967f1d078 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts index 3f125c3b0601..917967f1d078 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/oneOf/runtime.ts b/samples/client/petstore/typescript-fetch/builds/oneOf/runtime.ts index c807c6354f8d..859365935e74 100644 --- a/samples/client/petstore/typescript-fetch/builds/oneOf/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/oneOf/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts index 3f125c3b0601..917967f1d078 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts index 3f125c3b0601..917967f1d078 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts index 6d3d965df11d..0296a2863f5b 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/validation-attributes/runtime.ts b/samples/client/petstore/typescript-fetch/builds/validation-attributes/runtime.ts index 3f125c3b0601..917967f1d078 100644 --- a/samples/client/petstore/typescript-fetch/builds/validation-attributes/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/validation-attributes/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 3f125c3b0601..917967f1d078 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts index 3f125c3b0601..917967f1d078 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts index 8095de29bc32..c4c63d2df81f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts index 1d27e4d7e3ba..7e6bbc0079ca 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts @@ -261,6 +261,12 @@ export class ResponseError extends Error { override name: "ResponseError" = "ResponseError"; constructor(public response: Response, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -268,6 +274,12 @@ export class FetchError extends Error { override name: "FetchError" = "FetchError"; constructor(public cause: Error, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } } @@ -275,6 +287,12 @@ export class RequiredError extends Error { override name: "RequiredError" = "RequiredError"; constructor(public field: string, msg?: string) { super(msg); + + // restore prototype chain + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } } }