@@ -15,7 +15,7 @@ export function isAtLeastReact17(version: string): boolean {
15
15
export const UNKNOWN_COMPONENT = 'unknown' ;
16
16
17
17
export type FallbackRender = ( errorData : {
18
- error : Error ;
18
+ error : unknown ;
19
19
componentStack : string ;
20
20
eventId : string ;
21
21
resetError ( ) : void ;
@@ -40,15 +40,15 @@ export type ErrorBoundaryProps = {
40
40
*/
41
41
fallback ?: React . ReactElement | FallbackRender | undefined ;
42
42
/** Called when the error boundary encounters an error */
43
- onError ?: ( ( error : Error , componentStack : string , eventId : string ) => void ) | undefined ;
43
+ onError ?: ( ( error : unknown , componentStack : string , eventId : string ) => void ) | undefined ;
44
44
/** Called on componentDidMount() */
45
45
onMount ?: ( ( ) => void ) | undefined ;
46
46
/** Called if resetError() is called from the fallback render props function */
47
- onReset ?: ( ( error : Error | null , componentStack : string | null , eventId : string | null ) => void ) | undefined ;
47
+ onReset ?: ( ( error : unknown , componentStack : string | null , eventId : string | null ) => void ) | undefined ;
48
48
/** Called on componentWillUnmount() */
49
- onUnmount ?: ( ( error : Error | null , componentStack : string | null , eventId : string | null ) => void ) | undefined ;
49
+ onUnmount ?: ( ( error : unknown , componentStack : string | null , eventId : string | null ) => void ) | undefined ;
50
50
/** Called before the error is captured by Sentry, allows for you to add tags or context using the scope */
51
- beforeCapture ?: ( ( scope : Scope , error : Error | null , componentStack : string | null ) => void ) | undefined ;
51
+ beforeCapture ?: ( ( scope : Scope , error : unknown , componentStack : string | undefined ) => void ) | undefined ;
52
52
} ;
53
53
54
54
type ErrorBoundaryState =
@@ -59,7 +59,7 @@ type ErrorBoundaryState =
59
59
}
60
60
| {
61
61
componentStack : React . ErrorInfo [ 'componentStack' ] ;
62
- error : Error ;
62
+ error : unknown ;
63
63
eventId : string ;
64
64
} ;
65
65
@@ -118,7 +118,7 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
118
118
}
119
119
}
120
120
121
- public componentDidCatch ( error : Error & { cause ?: Error } , { componentStack } : React . ErrorInfo ) : void {
121
+ public componentDidCatch ( error : unknown , { componentStack } : React . ErrorInfo ) : void {
122
122
const { beforeCapture, onError, showDialog, dialogOptions } = this . props ;
123
123
withScope ( scope => {
124
124
// If on React version >= 17, create stack trace from componentStack param and links
@@ -200,9 +200,9 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
200
200
if ( typeof fallback === 'function' ) {
201
201
element = React . createElement ( fallback , {
202
202
error : state . error ,
203
- componentStack : state . componentStack ,
203
+ componentStack : state . componentStack as string ,
204
204
resetError : this . resetErrorBoundary ,
205
- eventId : state . eventId ,
205
+ eventId : state . eventId as string ,
206
206
} ) ;
207
207
} else {
208
208
element = fallback ;
0 commit comments