From a0e71d5adde315bc071d954b7029ae0dbcded00e Mon Sep 17 00:00:00 2001 From: sid <48153483+siddsriv@users.noreply.github.com> Date: Thu, 2 Jan 2025 17:35:47 -0500 Subject: [PATCH] fix(smithy-client): remove support for instanceof operator in ServiceException (#1486) * fix(smithy-client): remove support for instanceof operator in ServiceException * chore(smithy-client): add changeset --- .changeset/curvy-cups-fly.md | 5 +++++ packages/smithy-client/src/exceptions.spec.ts | 14 -------------- packages/smithy-client/src/exceptions.ts | 4 ---- 3 files changed, 5 insertions(+), 18 deletions(-) create mode 100644 .changeset/curvy-cups-fly.md diff --git a/.changeset/curvy-cups-fly.md b/.changeset/curvy-cups-fly.md new file mode 100644 index 00000000000..5e934c90817 --- /dev/null +++ b/.changeset/curvy-cups-fly.md @@ -0,0 +1,5 @@ +--- +"@smithy/smithy-client": minor +--- + +fix(smithy-client): remove support for instanceof operator diff --git a/packages/smithy-client/src/exceptions.spec.ts b/packages/smithy-client/src/exceptions.spec.ts index fc591f96a3e..5aecb9553db 100644 --- a/packages/smithy-client/src/exceptions.spec.ts +++ b/packages/smithy-client/src/exceptions.spec.ts @@ -69,20 +69,6 @@ describe("ServiceException type checking", () => { expect(ServiceException.isInstance({ $metadata: {} })).toBe(false); }); }); - - describe("instanceof", () => { - it("should return true for ServiceException instances", () => { - expect(error instanceof ServiceException).toBe(true); - }); - - it("should return true for duck-typed objects", () => { - expect(duckTyped instanceof ServiceException).toBe(true); - }); - - it("should return false for invalid objects", () => { - expect({} instanceof ServiceException).toBe(false); - }); - }); }); describe("decorateServiceException", () => { diff --git a/packages/smithy-client/src/exceptions.ts b/packages/smithy-client/src/exceptions.ts index 298fd40a65a..922c230f229 100644 --- a/packages/smithy-client/src/exceptions.ts +++ b/packages/smithy-client/src/exceptions.ts @@ -50,10 +50,6 @@ export class ServiceException extends Error implements SmithyException, Metadata (candidate.$fault === "client" || candidate.$fault === "server") ); } - - public static [Symbol.hasInstance](instance: unknown) { - return ServiceException.isInstance(instance); - } } /**