Definitelytyped: react-router: incompatible with latest "history" type definitions.

Created on 16 Jan 2017  路  10Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the latest react-router/index.d.ts file in this repo and had problems.

    • The dependency to the history package types is set to * and installs version 4.5 instead of 2.0 which is not compatible. react-router uses history@^3.0.0 which matches @types/[email protected]. The dependency between the type definitions should be properly set.

  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).

    • Why are dependencies between type definitions set to "*" instead of a specific version number? This is one of the major pain points when using TypeScript and breaks project templates and CI builds quite often. Is there no way around that besides manually inspecting dependencies between type definitions and require specific versions in the project's package.json file? I know there is npm shrinkwrap but that doesn't work for project templates where you want to start with the latest versions of the required packages. Also, when upgrading dependencies it quickly becomes a problem.

    • Wouldn't it make sense to set the DefinitelyTyped repository up as mono repo and to have a package.json per type definition package (e.g. with Lerna)? This way package authors could specify the dependencies properly.

  • [ ] I want to talk about xxxx/xxxx.d.ts.

    • The authors of that type definition are cc/ @sergey-buturlakin, @mrk21, @vasek17, @ngbrown, @awendland, @KostyaEsmukov

Most helpful comment

If you want to install an older version, use e.g. npm install @types/react-router@2.

All 10 comments

Same issue for me too. You can found the error messages below:
image

Thanks

I have hit this same issue--manually installing @types/history@^2.0.0 seems to have solved it.

I'm having this same exact issue.

I'm also having the same issue, what I did to allow for a successful build is to install @types/history version 2.0.44.
Version 2.0.44 was the version that was working for me before this issue.
npm install @types/[email protected]
Consider this a temporary workaround until the proper version is place instead of *.

I believe this issue relates to this setting in react-router/tsconfig.json:

{
    "compilerOptions": {
        "paths": {
            "history": ["history/v2"]
        }
    }
}

The type defs in history are indeed incompatible with the current react-router defs, but the ones in history/v2 look OK.

Moreover, the npm package for @types/react-router depends on @types/history that, in turn, was exported form history instead of history/v2.

I find it surprising that react-router will automatically pull in even major version changes from its children. This seems to guarantee errors. I think it should at most pull in only minor changes and preferably only patch changes.

Related PR #14035

This is fixed now. npm info @types/react-router dependencies

I tried to install @types/react-router-redux (in my own project):
npm install --save @types/react-router-redux
But it doesn't contain "v2" or "v3" folder in node_modules.
What am I doing wrong?
image

If you want to install an older version, use e.g. npm install @types/react-router@2.

Was this page helpful?
0 / 5 - 0 ratings