Skip to content

Commit

Permalink
fix: avoid instanceof Object check in isErrorLike
Browse files Browse the repository at this point in the history
#8497 does not seem to have been fully resolved for me with 14.4.0 (#8504), likely because the `instanceof` check being changed in this PR also causes issues in Jest due to jestjs/jest#2549. I was able to confirm that this change avoids the error I've been seeing in CI by testing this change via `patch-package`.
  • Loading branch information
jimmydief committed Jun 16, 2022
1 parent f0c1737 commit 222c4f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/util.ts
Expand Up @@ -407,7 +407,7 @@ 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 {
Expand Down

0 comments on commit 222c4f4

Please sign in to comment.