fix: avoid instanceof Object check in isErrorLike (#8527)

This commit is contained in:
James Diefenderfer 2022-06-17 06:26:18 -07:00 committed by GitHub
parent f0c17378a0
commit 6cd5cd0439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {