From ad57f7c0341364198c500dd7abb744e8e5166853 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Sat, 12 Aug 2023 23:44:55 +0200 Subject: [PATCH] Type safe error name checks --- packages/api/src/utils/client/fetch.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api/src/utils/client/fetch.ts b/packages/api/src/utils/client/fetch.ts index bc3502300b52..2cdd98a27af0 100644 --- a/packages/api/src/utils/client/fetch.ts +++ b/packages/api/src/utils/client/fetch.ts @@ -146,9 +146,9 @@ function isNativeFetchInputError(e: unknown): e is NativeFetchInputError { } function isNativeFetchAbortError(e: unknown): e is NativeFetchAbortError { - return e instanceof DOMException && e.name === "AbortError"; + return e instanceof DOMException && (e as NativeFetchAbortError).name === "AbortError"; } function isNativeFetchTimeoutError(e: unknown): e is NativeFetchTimeoutError { - return e instanceof DOMException && e.name === "TimeoutError"; + return e instanceof DOMException && (e as NativeFetchTimeoutError).name === "TimeoutError"; }