Problem with importing a separate hash module in Typescript
- Dominant language
- JavaScript
- Stars
- 323
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
According to docs one can import a separate hash module like this:
```ts
import sha from `hash.js/lib/hash/sha/512`;
```
But in this case Typescript emits the following error:
```
TS2307: Cannot find module 'hash.js/lib/hash/sha/512'
```
This can be fixed by creating a type definition file in user-land with the following contents:
```ts
// hashjs.d.ts
declare module 'hash.js/lib/hash/sha/1' {
import {sha1} from 'hash.js';
export = sha1;
}
```
But it would be awesome to support such imports out of the box.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the TypeScript error for the documented import of hash.js/lib/hash/sha/512 and review the example hashjs.d.ts declaration. The work is done when the separate hash module resolves without a user-land declaration file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100