remix-run / history

Manage session history with JavaScript
MIT License
8.3k stars 960 forks source link

Did TS declaration file disappear for v4? #937

Closed bmueller-sykes closed 2 years ago

bmueller-sykes commented 2 years ago

Apologies if this is not the right place for this. As of a couple of days ago, I cannot get my TS-based React project to start in dev mode. I'm running v4.10.1 at present, and cannot upgrade to v5 (I still rely on basename for some parts of my code, and cannot easily refactor those parts yet. Someday...).

When I run npm start I get the following error:

Could not find a declaration file for module 'history'. '/path/to/project/node_modules/history/index.js' implicitly has an 'any' type.
If the 'history' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/history'

1 | import { useHistory } from 'react-router-dom';
2 | import { createBrowserHistory } from 'history';

Any guidance is appreciated. Thanks!

Beraliv commented 2 years ago

Same story for us

We cannot upgrade to v5, but still need type definitions for v4

mcansh commented 2 years ago

type definitions for versions prior to v5 are available via DefinitelyTyped (just make sure to use the v4 version of the types)

Beraliv commented 2 years ago

Okay, thank you for the quick answer!

Worked for us

bmueller-sykes commented 2 years ago

Yeah, that worked for me as well, it would appear. I looked for that type file, but couldn't find it initially for some reason, but adding this to my devDependencies in package.json:

`"@types/history": "4.7.11",

...did the trick