Bitcoinjs-lib: typescript type annotations

Created on 4 Jul 2017  路  10Comments  路  Source: bitcoinjs/bitcoinjs-lib

i ported a project that uses bitcoinjs-lib 3.0.3 to typescript and on the process i generated type declaration files that work well with the library, facilitatiing linting, autocompletion over the namespaces and displaying the parameter and types for functions. I left many functions that take optional parameters as obligatory on my type definitions, as i havent studied the library carefully to fix that.

would there be any interest in integrating this type annotations to the package? if so i could submit a PR

best
d

how to / question / docs

All 10 comments

I think they are managed externally at the moment.
Do you feel they need to be integrated?

(1) the recommended way is to add the types straight to the original library.

(2) the second option is to add using definitely typed, so that one can install the declaration files using

npm install --save-dev @types/bitcoinjs-lib

the issue with this approach: there seems to be no real mechanism of handling different type declarations for different versions of the library.

in any case i have a PR to include the type definitions https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17704 so that one can use this second approach. With the help of @rbuckton, now the type declarations are complete and of high quality.

after that PR gets merged and the package published to npm, I will send a PR here simply updating the README on how to install the declaration files for typescript. how does that sound to u?

after that PR gets merged and the package published to npm, I will send a PR here simply updating the README on how to install the declaration files for typescript. how does that sound to u?

Sounds good :+1:

Will re-open if anyone takes this on

im almost done with the typedefinitions. have some trouble with the re-exports done in templates. its tedious to figure them out. only missing the witness* stuff as of now.

realised that the typedefinitions are usefull even when coding in javascript if using an editor like microsoft code, as it does some static analysis on the js code.

i'd accept suggestions of high quality open source projects using the bitcoinjs-lib so that i can test that they type check using our type definitions. in special something using the witness* as our project doesnt use it currently

please reopen this issue. i'll complete it till the end of the month and submit a PR for the README

@dlebrecht https://www.npmjs.com/browse/depended/bitcoinjs-lib might help you find dependents using a recent version

i added a PR to the definitely typed library.

https://github.com/DefinitelyTyped/DefinitelyTyped/pull/18932

@dcousens or someone expert in bitcoinjs-lib: could someone have a look at the definitions, in special, from line 425 to 531, as i did them by hand? https://github.com/DefinitelyTyped/DefinitelyTyped/pull/18932/files and comment on them over there if they seem wrong or incomplete.

in general, i suspect there are some optional parameters to functions that the current type definitions depict as compulsory.

thanks @dcousens

here's the new pull request after ur comments
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/18961

@dlebrecht nice! I can't guarantee that there weren't other issues - but they were the problems I saw from a quick glance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbndg picture rbndg  路  3Comments

silence-may picture silence-may  路  3Comments

askucher picture askucher  路  3Comments

prahaladbelavadi picture prahaladbelavadi  路  3Comments

tuyennvtb picture tuyennvtb  路  3Comments