-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
Problem
When using this package in a typescript project, the typescript compiler will error on packages imported without type information:
❯ npm run build
> test-out-pear-api@1.0.0 build
> tsc
src/index.ts:1:17 - error TS7016: Could not find a declaration file for module 'hyperdht'. '/Users/samholmes/Developer/test-out-pear-api/node_modules/hyperdht/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/hyperdht` if it exists or add a new declaration (.d.ts) file containing `declare module 'hyperdht';`
1 import DHT from 'hyperdht'
~~~~~~~~~~
Found 1 error in src/index.ts:1
In addition to this, developer experience is diminished when editor integrations complain:
Solution
Add a index.d.ts file to the project describing the exported types from the package and include this in the "types" field in package.json:
export default class DHT {
constructor()
// ...
}Footnote
I'm going to fork this repo and begin work on this effort to improve the project's documentation through type definitions and JSDocs. I'll be reaching out to the appropriate persons to make sure I get the types mostly correct before submitting a pull-request.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels