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

Getting Typescript errors when upgrading to React 18 #4904

Closed
3 tasks done
gxxcastillo opened this issue Apr 8, 2022 · 4 comments · Fixed by #4966
Closed
3 tasks done

Getting Typescript errors when upgrading to React 18 #4904

gxxcastillo opened this issue Apr 8, 2022 · 4 comments · Fixed by #4966

Comments

@gxxcastillo
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/react

SDK Version

6.19.6

Framework Version

6.19.6

Link to Sentry event

No response

Steps to Reproduce

Hi, I've started getting the following Typescript errors in my build. It seems it has to do with ErrorBoundaryProps not having a children property declared. Adding children: React.ReactNode to ErrorBoundaryProps fixed the issue for me.

DefinitelyTyped/DefinitelyTyped#46691

Expected Result

Typescript errors should not occur when React.ErrorBoundary has children

Actual Result

No overload matches this call.
  Overload 1 of 2, '(props: ErrorBoundaryProps | Readonly<ErrorBoundaryProps>): ErrorBoundary', gave the following error.
    Type '{ children: Element; fallback: Element; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ErrorBoundary> & Readonly<ErrorBoundaryProps>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ErrorBoundary> & Readonly<ErrorBoundaryProps>'.
  Overload 2 of 2, '(props: ErrorBoundaryProps, context: any): ErrorBoundary', gave the following error.
    Type '{ children: Element; fallback: Element; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<ErrorBoundary> & Readonly<ErrorBoundaryProps>'.
      Property 'children' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ErrorBoundary> & Readonly<ErrorBoundaryProps>'
@AbhiPrasad
Copy link
Member

Hey thanks for reporting. We’re currently busy working on the new major version, #4882 but we’ll get to this afterwards!

@gxxcastillo
Copy link
Author

Thanks @AbhiPrasad.

In case anyone else runs into this, the quickest fix for now is probably to ignore the error (I had trouble with module augmentation, I think because ErrorBoundaryProps is not exported?). It should allow your build to proceed but you'll want to comeback and remove it once this issue is resolved:

{/* @ts-expect-error - Temporary Fix */}

sue445 added a commit to sue445/primap that referenced this issue Apr 9, 2022
@cameronaziz
Copy link
Contributor

I have opened #4966 to fix this issue

@lforst
Copy link
Member

lforst commented Apr 26, 2022

We are resolving this with our next patch (version 6.19.7) so keep an eye out for updates and remember to remove your @ts-expect-errors. Let us know here if you run into any more issues.

Thanks @cameronaziz for the initiative!

Update: The patch is out https://github.com/getsentry/sentry-javascript/releases/tag/6.19.7

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

Successfully merging a pull request may close this issue.

4 participants