Skip to content

Types for ErrorBoundary fallback props seems wrong #4190

@tkrotoff

Description

@tkrotoff

Package + Version

  • @sentry/react

Version:

6.15.0

Description

fallback props from ErrorBoundary is defined as

...
error: Error;
componentStack: string | null;
eventId: string | null;
...

When fallback is called, eventId and componentStack cannot be null because error is not null and error, eventId, componentStack are set at the same time.

Proper types:

...
error: Error;
componentStack: string | null;
eventId: string | null;
...

Instead of:

// https://github.com/getsentry/sentry-javascript/blob/6.15.0/packages/react/src/errorboundary.tsx#L131
fallback({ error, componentStack, resetError: this.resetErrorBoundary, eventId });

it should be:

fallback({ error, componentStack!, resetError: this.resetErrorBoundary, eventId! });

because you know eventId and componentStack are not null.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions