Skip to content
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

feat: remove as Error type assertions #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghost91-
Copy link
Contributor

Instead, errors are now consistently typed as unknown.

BREAKING CHANGE: The types of errors have been changed from Error to unknown because they are not statically known (in JavaScript, anything can be thrown). If you know that in a particular situation, errors can only be instances of Error, you can do the type assertion yourself (error as Error). Otherwise, you should check whether an error is actually an Error, for example with error instanceof Error.

Closes #87

Instead, errors are now consistently typed as `unknown`.

BREAKING CHANGE: The types of errors have been changed from `Error` to unknown because they are not statically known (in JavaScript, _anything_ can be thrown).
If you know that in a particular situation, errors can only be instances of
`Error`, you can do the type assertion yourself (`error as Error`). Otherwise,
you should check whether an error is actually an `Error`, for example with
`error instanceof Error`.

Closes connor4312#87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Consider removing casts to Error when catching
1 participant