Skip to content

Typescript build errors when using in app with React Router 6 #107

Description

@AlexZeitler

I've migrated an app to React 18 / Router v6 and vite build results in these errors:

node_modules/@types/react-router-dom/index.d.ts:13:10 - error TS2305: Module '"react-router"' has no exported member 'match'.

13 import { match } from 'react-router';
            ~~~~~

node_modules/@types/react-router-dom/index.d.ts:19:5 - error TS2305: Module '"react-router"' has no exported member 'PromptProps'.

19     PromptProps,
       ~~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:20:5 - error TS2305: Module '"react-router"' has no exported member 'Prompt'.

20     Prompt,
       ~~~~~~

node_modules/@types/react-router-dom/index.d.ts:23:5 - error TS2305: Module '"react-router"' has no exported member 'RedirectProps'.

23     RedirectProps,
       ~~~~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:24:5 - error TS2724: '"react-router"' has no exported member named 'Redirect'. Did you mean 'redirect'?

24     Redirect,
       ~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:25:5 - error TS2305: Module '"react-router"' has no exported member 'RouteChildrenProps'.

25     RouteChildrenProps,
       ~~~~~~~~~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:26:5 - error TS2305: Module '"react-router"' has no exported member 'RouteComponentProps'.

26     RouteComponentProps,
       ~~~~~~~~~~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:31:5 - error TS2305: Module '"react-router"' has no exported member 'StaticRouterProps'.

31     StaticRouterProps,
       ~~~~~~~~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:32:5 - error TS2305: Module '"react-router"' has no exported member 'StaticRouter'.

32     StaticRouter,
       ~~~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:33:5 - error TS2305: Module '"react-router"' has no exported member 'SwitchProps'.

33     SwitchProps,
       ~~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:34:5 - error TS2305: Module '"react-router"' has no exported member 'Switch'.

34     Switch,
       ~~~~~~

node_modules/@types/react-router-dom/index.d.ts:35:5 - error TS2305: Module '"react-router"' has no exported member 'match'.

35     match,
       ~~~~~

node_modules/@types/react-router-dom/index.d.ts:37:5 - error TS2305: Module '"react-router"' has no exported member 'withRouter'.

37     withRouter,
       ~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:38:5 - error TS2305: Module '"react-router"' has no exported member 'RouterChildContext'.

38     RouterChildContext,
       ~~~~~~~~~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:39:5 - error TS2305: Module '"react-router"' has no exported member 'useHistory'.

39     useHistory,
       ~~~~~~~~~~

node_modules/@types/react-router-dom/index.d.ts:42:5 - error TS2724: '"react-router"' has no exported member named 'useRouteMatch'. Did you mean 'RouteMatch'?

42     useRouteMatch,
       ~~~~~~~~~~~~~

node_modules/@types/react-router-hash-link/index.d.ts:19:18 - error TS2320: Interface 'NavHashLinkProps' cannot simultaneously extend types 'NavLinkProps' and 'Omit<HashLinkProps, "style" | "className">'.
  Named property 'children' of types 'NavLinkProps' and 'Omit<HashLinkProps, "style" | "className">' are not identical.

19 export interface NavHashLinkProps extends NavLinkProps, Omit<HashLinkProps, 'className' | 'style'> { }

This seems to be caused by this dependency in yarn.lock:

"@types/react-router-dom@^5.3.0":
  version "5.3.3"
  resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.3.3.tgz#e9d6b4a66fcdbd651a5f106c2656a30088cc1e83"
  integrity sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw==
  dependencies:
    "@types/history" "^4.7.11"
    "@types/react" "*"
    "@types/react-router" "*"

"@types/react-router-hash-link@^2.4.6":
  version "2.4.6"
  resolved "https://registry.yarnpkg.com/@types/react-router-hash-link/-/react-router-hash-link-2.4.6.tgz#6411fb185e126bb1b985c6867a0e413670082f34"
  integrity sha512-JOV4Q1N60tJJUPisS/u1jiXn8c4jX7ThQf8XavzZYIWOIv0RP17nbyI9YgEZh1r3APXpP9ZkU1ytrlv+1+8jcw==
  dependencies:
    "@types/history" "^4.7.11"
    "@types/react" "*"
    "@types/react-router-dom" "^5.3.0"

Is there something I can do about it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions