-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add isErrorObject
type guard / function
#47
Comments
What would you use it for that is related to this package? |
To detect whether is a serialized error or regular error. Example: try {
…
} catch(error: unknown) {
if (isErrorObject(error) && error.message === blah) {
// ignore
} else {
throw error
}
} Typescript makes it a pain to check properties of unknown objects, even with |
Yes, but why have it here and not in https://github.com/sindresorhus/is? And what properties should it enforce? I think it should be named https://stackoverflow.com/questions/43712705/why-does-typescript-use-like-types |
Here because
In this package the type ErrorObject could also make a little more tight because currently it matches |
Ah, I see. Ok, sure, let's add. |
What do you think about exporting a type-checker function (like
Array.isArray
) that doubles as a type guard?The text was updated successfully, but these errors were encountered: