Closed torkelrogstad closed 4 years ago
@bmancini55, would it be possible to get some feedback/progress on this?
Apologies on the delay. Fantastic job putting this together! It's much appreciated and excellent work!
I did find one issue with with CommonJS imports. The only type at the root import is default
. After you reference default, the connect method is available. So should hopefully be an easy fix.
Other than that... due to the size of the TypeScript file, I think this would be better stored in the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped) and referenced in the lnd-async Readme. This way we can keep the lnd-async library just the source code pertaining to the project. Thoughts?
Having them in DefinitelyTyped is reasonable when they're so large. Would it be appropriate to keep the notes on how to generate the types in README? A link to DefinitelyTyped could also be included.
Certainly, I think that would make perfect sense to keep both information about generating type defs and instructions on how to include typing in your project in the README.
Hi @torkelrogstad. Great work! Any progress on moving this to DefinitelyTyped?
I have not done any more work on this, I'm afraid. I don't use TS day to day any more, so haven't been a priority.
Feel free to either push to this PR, close it, use the code for a DefinitelyTyped PR, or something else entirely:-)
Closes #7
Adds TypeScript definitions for this library. They were mostly automatically generated, using the tool pbjs from the protobufjs library. See README.md for details.
After being generated, most of the work consisted of removing all references to callbacks (as this library is all about promises), removing some unused classes and tweaking some definitions. In particular, openChannel and sendPayment were (and probably others as well) not correct. Using conditional typings I managed to get some pretty nice type inference on the various event listeners. Similar work can probably be done on other methods as well. There were also some work done on removing all references to number | Long (I replaced them all with just number), and lot's of places where the definitions would suggest the API returns null or undefined. If the call succeedes, that should never happen, AFAIK.