mivion / swisseph

Swiss Ephemeris binding for node.js
GNU General Public License v2.0
205 stars 72 forks source link

typescript support? #77

Closed codelocksdev closed 3 years ago

codelocksdev commented 3 years ago

Do you have any plans to include typescript support for this package?

Thanks so much!

krisztianb commented 3 years ago

You mean TypeScript type definitions, right?

Browsing through the depending packages on NPM I found this: https://github.com/milanpredic/astrochart/blob/master/src/%40types/swisseph/index.d.ts

All tough it uses a lot of any so I might give it a shot and improve it.

krisztianb commented 3 years ago

Just to give interested folks a heads up on this: I'm currently working on the type definitions for this library. I guess I'll still need at least a week to get it done and submit a PR as I'm testing everything that I do.

roabhi commented 3 years ago

If you just want to use swisseph in you project you can always declare the module like

declare module "swisseph"

You're not going to get any types but at least it is usable. Btw I am also working on a TS project with swisseph so if anyone is looking for help creating definitions let me know.

Cheers.

krisztianb commented 3 years ago

If you just want to use swisseph in you project you can always declare the module like

declare module "swisseph"

You're not going to get any types but at least it is usable.

Sure. That's defining the module without types mapping every type to "any". Which is precisely what you don't want in a TypeScript project. :smile:

Btw I am also working on a TS project with swisseph so if anyone is looking for help creating definitions let me know.

Cheers.

Thanks for letting me know. I'm taking the types from the official Swiss Ephemeris documentation and the C++ code of this project. I'm also adding comments to every function and its parameters to improve intelisense in VSCode for example.

roabhi commented 3 years ago

Sure. That's defining the module without types mapping every type to "any". Which is precisely what you don't want in a TypeScript project.

Yeah of course, that was the only way for me to at least making the code to transpile with tsc in the meantime but I am looking for a more consistent solution moving forward

Thanks for letting me know. I'm taking the types from the official Swiss Ephemeris documentation and the C++ code of this project. I'm also adding comments to every function and its parameters to improve intelisense in VSCode for example.

That's just awesome :)

I am not very versed in C++, neither TS as a matter of fact...but will take a look at those types and see if I am able to grasp anything.

Cheers

krisztianb commented 3 years ago

PR is open: https://github.com/mivion/swisseph/pull/82