Skip to content

[Bug]: typings seem to break with v6.4.2 #9427

@liztownd

Description

@liztownd

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.

Compiled with problems:X

ERROR in src/AppRoutes.ts:3:40

TS2312: An interface can only extend an object type or intersection of object types with statically known members.
    1 | import { RouteProps } from "react-router-dom";
    2 |
  > 3 | export interface AppRouteProps extends RouteProps {
      |                                        ^^^^^^^^^^
    4 |   title: string;
    5 |   // A set of properties for making a mappable list
    6 |   url?: string;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions