Skip to content

npm install @types/react-router #9488

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

Closed
basarat opened this issue Jul 2, 2016 · 14 comments
Closed

npm install @types/react-router #9488

basarat opened this issue Jul 2, 2016 · 14 comments
Labels
Bug A bug in TypeScript @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped

Comments

@basarat
Copy link
Contributor

basarat commented Jul 2, 2016

There is a bug in typings http://stackoverflow.com/questions/38157103/dtreact-router-error-ts2503-cannot-find-namespace-historymodule so I thought I'd give @types a go. However that didn't do a stellar job either.

npm install @types/react-router
tsc --init
tsc -p .

Errors:

node_modules/@types/react-router/index.d.ts(10,20): error TS2307: Cannot find module './lib/Router'.
node_modules/@types/react-router/index.d.ts(11,18): error TS2307: Cannot find module './lib/Link'.
node_modules/@types/react-router/index.d.ts(12,23): error TS2307: Cannot find module './lib/IndexLink'.
node_modules/@types/react-router/index.d.ts(13,27): error TS2307: Cannot find module './lib/IndexRedirect'.
node_modules/@types/react-router/index.d.ts(14,24): error TS2307: Cannot find module './lib/IndexRoute'.
node_modules/@types/react-router/index.d.ts(15,22): error TS2307: Cannot find module './lib/Redirect'.
node_modules/@types/react-router/index.d.ts(16,19): error TS2307: Cannot find module './lib/Route'.
node_modules/@types/react-router/index.d.ts(17,26): error TS2307: Cannot find module './lib/History'.
node_modules/@types/react-router/index.d.ts(18,23): error TS2307: Cannot find module './lib/Lifecycle'.
node_modules/@types/react-router/index.d.ts(19,26): error TS2307: Cannot find module './lib/RouteContext'.
node_modules/@types/react-router/index.d.ts(20,28): error TS2307: Cannot find module './lib/browserHistory'.
node_modules/@types/react-router/index.d.ts(21,25): error TS2307: Cannot find module './lib/hashHistory'.
node_modules/@types/react-router/index.d.ts(22,23): error TS2307: Cannot find module './lib/useRoutes'.
node_modules/@types/react-router/index.d.ts(23,30): error TS2307: Cannot find module './lib/RouteUtils'.
node_modules/@types/react-router/index.d.ts(24,31): error TS2307: Cannot find module './lib/PatternUtils'.
node_modules/@types/react-router/index.d.ts(25,27): error TS2307: Cannot find module './lib/RouterContext'.
node_modules/@types/react-router/index.d.ts(26,23): error TS2307: Cannot find module './lib/PropTypes'.
node_modules/@types/react-router/index.d.ts(27,19): error TS2307: Cannot find module './lib/match'.
node_modules/@types/react-router/index.d.ts(28,30): error TS2307: Cannot find module './lib/useRouterHistory'.
node_modules/@types/react-router/index.d.ts(29,33): error TS2307: Cannot find module './lib/createMemoryHistory'.

Where should people put @types issues? 🌹

@JabX
Copy link

JabX commented Jul 2, 2016

I have the same issue with the history module. It looks like the problem is that npm install @types/** only takes the index.d.ts file and ignores the lib directory.

@mhegazy mhegazy added the Bug A bug in TypeScript label Jul 4, 2016
@mhegazy mhegazy added this to the TypeScript 2.0 milestone Jul 4, 2016
@mhegazy mhegazy self-assigned this Jul 4, 2016
@mhegazy mhegazy added the @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped label Jul 4, 2016
@rhmoller
Copy link

rhmoller commented Jul 6, 2016

I don't think the problem is with npm install. It is more likely the tool that has moved the typings from DefinitelyTyped to @types that is the problem

@JabX
Copy link

JabX commented Jul 6, 2016

The types 2.0 branch of DefinetelyTyped has all the files, and I assumed it was published to NPM from there.

@rhmoller
Copy link

rhmoller commented Jul 6, 2016

Looks like the types-publisher does not scan for .d.ts in subfolders.
https://github.com/Microsoft/types-publisher/blob/master/src/lib/definition-parser.ts#L74

@mhegazy mhegazy assigned ghost and unassigned mhegazy Jul 8, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.0.1, TypeScript 2.0 Jul 8, 2016
@mhegazy mhegazy removed this from the TypeScript 2.0.1 milestone Jul 11, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jul 11, 2016
@dalgard
Copy link

dalgard commented Jul 28, 2016

How can I get this fix?

I've installed @types/react-router today and the error still occurs.

@yvbeek
Copy link

yvbeek commented Aug 16, 2016

I am having the same problem:

node_modules/@types/history/index.d.ts(120,42): error TS2307: Cannot find module './lib/createBrowserHistory'.
node_modules/@types/history/index.d.ts(121,46): error TS2307: Cannot find module './lib/createHashHistory'.
node_modules/@types/history/index.d.ts(122,48): error TS2307: Cannot find module './lib/createMemoryHistory'.
node_modules/@types/history/index.d.ts(123,43): error TS2307: Cannot find module './lib/createLocation'.
node_modules/@types/history/index.d.ts(124,40): error TS2307: Cannot find module './lib/useBasename'.
node_modules/@types/history/index.d.ts(125,44): error TS2307: Cannot find module './lib/useBeforeUnload'.
node_modules/@types/history/index.d.ts(126,39): error TS2307: Cannot find module './lib/useQueries'.
node_modules/@types/react-router/react-router.d.ts(13,20): error TS2503: Cannot find namespace '__React'.
node_modules/@types/react-router/react-router.d.ts(347,14): error TS2503: Cannot find namespace '__React'.
node_modules/@types/react-router/react-router.d.ts(369,20): error TS2503: Cannot find namespace '__React'.
node_modules/@types/redux-router/lib/isActive.d.ts(3,46): error TS2305: Module '"history"' has no exported member 'Pathname'.
node_modules/@types/redux-router/lib/isActive.d.ts(3,66): error TS2305: Module '"history"' has no exported member 'Query'.
node_modules/@types/redux-router/node_modules/@types/redux/index.d.ts(7,21): error TS2300: Duplicate identifier 'Redux'.
node_modules/@types/redux/index.d.ts(7,21): error TS2300: Duplicate identifier 'Redux'.
src/app/routes.tsx(7,13): error TS2604: JSX element type 'Route' does not have any construct or call signatures.

@RyanCavanaugh RyanCavanaugh reopened this Aug 16, 2016
@RyanCavanaugh RyanCavanaugh removed the Fixed A PR has been merged for this issue label Aug 16, 2016
@RyanCavanaugh
Copy link
Member

@Andy-MS can you see what's going on?

@mjrister
Copy link

This is marked as fixed, but I still get these compilation errors with using the latest react-router typescript definitions when using npm install @types/react-router --save

@mhegazy
Copy link
Contributor

mhegazy commented Dec 19, 2016

This is marked as fixed, but I still get these compilation errors with using the latest react-router typescript definitions when using npm install @types/react-router --save

c:\test\9488>npm install @types/react-router
[email protected] c:\test\9488
`-- @types/[email protected]
  +-- @types/[email protected]
  `-- @types/[email protected]

c:\test\9488>echo import { History } from 'react-router'; > index.ts

c:\test\9488>tsc --v
Version 2.1.4

c:\test\9488>tsc --init

c:\test\9488>tsc

c:\test\9488>echo %ERRORLEVEL%
0

@mjrister
Copy link

As detailed by this post, it only works if module resolution is set to node in tsconfig. DefinitelyTyped/DefinitelyTyped#10686. I was able to get around this by manually changing the imports of "history" to the relative path of the @types/history index definition

@mhegazy
Copy link
Contributor

mhegazy commented Dec 19, 2016

the resolution of these packages assumes a node-style resolution. so you need to use "moduleResolution": "node"

@mjrister
Copy link

We use AMD and therefore cannot use node module resolution. TypeScript definitions should be robust enough to handle all module types. Can we re-open this?

@ghost
Copy link

ghost commented Dec 19, 2016

The other issue that you linked to is still open and we're planning to fix it.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 19, 2016

i miss spoke. thanks @Andy-MS for the correction. the AMD should work. this issue seems to be caused by the @types package authoring. @Andy-MS is fixing it on Definitely Typed.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped
Projects
None yet
Development

No branches or pull requests

8 participants