From 6cd5cd043997699edca6e3458f90adc1118cf4a5 Mon Sep 17 00:00:00 2001 From: James Diefenderfer Date: Fri, 17 Jun 2022 06:26:18 -0700 Subject: [PATCH] fix: avoid `instanceof Object` check in `isErrorLike` (#8527) --- src/common/util.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/util.ts b/src/common/util.ts index f1e86a1a..5115ecf1 100644 --- a/src/common/util.ts +++ b/src/common/util.ts @@ -407,7 +407,9 @@ interface ErrorLike extends Error { } export function isErrorLike(obj: unknown): obj is ErrorLike { - return obj instanceof Object && 'name' in obj && 'message' in obj; + return ( + typeof obj === 'object' && obj !== null && 'name' in obj && 'message' in obj + ); } export function isErrnoException(obj: unknown): obj is NodeJS.ErrnoException {