-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[Bug]: typings seem to break with v6.4.2 #9427
Comments
Looks like this was changed to a union type in #9366. |
Ah - yeah we moved to discriminated unions for all of our Example of an invalid route setup: <Route index element={<Index />}>
<Route ... />
</Route> Can you adjust your types to use the following?
|
Yes, it will technically work now with that fix. |
How do i type
Above type throws me an error in
Now i have to write this hack:
|
@artuska If you override the
I set up a working example of this in https://codesandbox.io/s/extending-route-object-2dqjc8?file=/src/index.tsx - does this handle your use case? 6.4 also introduces the |
What version of React Router are you using?
6.4.2
Steps to Reproduce
Recently installed react-router-dom v 6.4.2 and now have errors related to typings (I'm using Typescript v 4.4.4 and @types/react-router-dom v 5.3.3). After the install I get this error related to RouteProps:
An interface can only extend an object type or intersection of object types with statically known members.
Even though when I click through the imported RouteProps it takes me to the interface and they are there in the declarations file.
From the
components.d.ts
file:export declare type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
Not sure if this is a compatibility issue with the @types library but switching back to react-router-dom 6.4.1 solves the typing issue.
Expected Behavior
The code compiles and runs. :(
Actual Behavior
The compiler throws errors and the code will not compile.
The text was updated successfully, but these errors were encountered: