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

fix(react): Make Route typing more generic #3809

Merged
merged 1 commit into from
Jul 15, 2021

Conversation

AbhiPrasad
Copy link
Member

DefinitelyTyped/DefinitelyTyped#51355 merging in
lead to some more robust type inference for React Router params. This
means that for Typescript >= 4.1.5, certain param types break when using
the withSentryRouting higher order component.

To fix this issue, we use a generic instead of a React component type
for the wrapped React component. As we have to use this generic instead
of a specific React type, we have to use @ts-ignore to make the JSX
expressions work with typescript.

Fixes #3808.

DefinitelyTyped/DefinitelyTyped#51355 merging in
lead to some more robust type inference for React Router params. This
means that for Typescript >= 4.1.5, certain param types break when using
the `withSentryRouting` higher order component.

To fix this issue, we use a generic instead of a React component type
for the wrapped React component. As we have to use this generic instead
of a specific React type, we have to use @ts-ignore to make the JSX
expressions work with typescript.

Fixes #3808
Copy link
Contributor

@kamilogorek kamilogorek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Types are so lovely 💩

@github-actions
Copy link
Contributor

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 21.46 KB (0%)
@sentry/browser - Webpack 22.47 KB (0%)
@sentry/react - Webpack 22.5 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.95 KB (0%)

@AbhiPrasad AbhiPrasad enabled auto-merge (squash) July 15, 2021 14:19
@AbhiPrasad AbhiPrasad merged commit 5f35c8c into master Jul 15, 2021
@AbhiPrasad AbhiPrasad deleted the abhi-fix-ts-react-router branch July 15, 2021 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[withSentryRouting] match param types are made optional
2 participants