diff --git a/packages/react/src/errorboundary.tsx b/packages/react/src/errorboundary.tsx index 7e68416a67ce..1553028195a2 100644 --- a/packages/react/src/errorboundary.tsx +++ b/packages/react/src/errorboundary.tsx @@ -13,8 +13,8 @@ export const UNKNOWN_COMPONENT = 'unknown'; export type FallbackRender = (errorData: { error: Error; - componentStack: string | null; - eventId: string | null; + componentStack: string; + eventId: string; resetError(): void; }) => React.ReactElement; @@ -48,11 +48,17 @@ export type ErrorBoundaryProps = { beforeCapture?(scope: Scope, error: Error | null, componentStack: string | null): void; }; -type ErrorBoundaryState = { - componentStack: React.ErrorInfo['componentStack'] | null; - error: Error | null; - eventId: string | null; -}; +type ErrorBoundaryState = + | { + componentStack: null; + error: null; + eventId: null; + } + | { + componentStack: React.ErrorInfo['componentStack']; + error: Error; + eventId: string; + }; const INITIAL_STATE = { componentStack: null, @@ -133,12 +139,17 @@ class ErrorBoundary extends React.Component