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

matchRoutes type is incompatible with routes parameter in react-router integration #5959

Closed
3 tasks done
rafael-zilberman opened this issue Oct 14, 2022 · 1 comment · Fixed by #5992
Closed
3 tasks done

Comments

@rafael-zilberman
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

7.15.0

Framework Version

17.0.2

Link to Sentry event

No response

Steps to Reproduce

Following the react-router integration documentation here:
https://docs.sentry.io/platforms/javascript/guides/react/configuration/integrations/react-router/

Using the following code:

import {
    createRoutesFromChildren,
    matchRoutes,
    useLocation,
    useNavigationType
} from "react-router-dom";

Sentry.init({
    dsn: process.env.REACT_APP_SENTRY_DSN,
    integrations: [new BrowserTracing({
        routingInstrumentation: Sentry.reactRouterV6Instrumentation(
            useEffect,
            useLocation,
            useNavigationType,
            createRoutesFromChildren,
            matchRoutes,
        ),
    }), new ExtraErrorDataIntegration(), new OfflineIntegration(), postHogIntegration],
    tracesSampleRate: 1.0,
});

Expected Result

No typescript error should be shown

Actual Result

Produces the following Typescript error:

TS2345: Argument of type '<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: string | Partial<Location>, basename?: string | undefined) => AgnosticRo
uteMatch<...>[] | null' is not assignable to parameter of type 'MatchRoutes'.
  Types of parameters 'routes' and 'routes' are incompatible.
    Type 'RouteObject[]' is not assignable to type 'AgnosticRouteObject[]'.
      Type 'RouteObject' is not assignable to type 'AgnosticRouteObject'.
        Type 'RouteObject' is not assignable to type 'AgnosticNonIndexRouteObject'.
          Type 'RouteObject' is not assignable to type '{ children?: AgnosticRouteObject[] | undefined; index?: false | undefined; }'.
            Types of property 'children' are incompatible.
              Type 'RouteObject[] | undefined' is not assignable to type 'AgnosticRouteObject[] | undefined'.
                Type 'RouteObject[]' is not assignable to type 'AgnosticRouteObject[]'.
                  Type 'RouteObject' is not assignable to type 'AgnosticRouteObject'.
                    Type 'RouteObject' is not assignable to type 'AgnosticNonIndexRouteObject'.
                      Types of property 'index' are incompatible.
                        Type 'boolean | undefined' is not assignable to type 'false | undefined'.
                          Type 'true' is not assignable to type 'false'.
    36 |                 useNavigationType,
    37 |                 createRoutesFromChildren,
  > 38 |                 matchRoutes,
       |                 ^^^^^^^^^^^
    39 |             ),
    40 |         }), new ExtraErrorDataIntegration(), new OfflineIntegration(), postHogIntegration],
    41 |         tracesSampleRate: 1.0,
@AbhiPrasad
Copy link
Member

AbhiPrasad commented Oct 14, 2022

Hey thanks for writing in! This may be fixed by #5915, will double check!

Edit: yeah it seems like it should! Will backlog as it seems there is the fix there.

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.

2 participants