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
React ErrorBoundary component is not type safe #11728
Comments
The react types says that only errors are passed into You're right though that we need to handle this case. |
@AbhiPrasad wow yeah, the react types are definitely wrong in that case :( |
merging in the PR to react types first, then will fix the types here! DefinitelyTyped/DefinitelyTyped#69434 |
🙇 Thank you! |
Seems like they'll only update the types for React 20 😭 - so I ended up closing my PR (it's on the TODO now though DefinitelyTyped/DefinitelyTyped#69436) Busy with releasing Node 22 support, but I'll make the SDK fix afterwards. Thanks for your patience in the meantime @RobinClowers! |
No problem, thanks for being so responsive! We already mitigated it in our app, so no worries. |
Fixes #11728 As reporting in the above issue, it is not typesafe to type the error thrown by react components as `Error`, it can actually be any JS object/primitive that was thrown. This means we have to type everything as `unknown`. This change only will happen for `8.x` because it's a breaking change. Related: - https://react.dev/reference/react/Component#componentdidcatch - DefinitelyTyped/DefinitelyTyped#69434 --------- Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
7.111.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
Sentry.ErrorBoundary
Expected Result
The type of the
error
object should beunknown
, since you canthrow
any object in javascript.Actual Result
The
error
object is typed asError
, which can lead to runtime errors.The text was updated successfully, but these errors were encountered: