-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish TypeScript typings #285
Comments
An interesting project would be to translate the upstream source directly to TypeScript. |
So... any news on TypeScript ? the TypeDef available on DefinitlyTyped are incomplete :-( |
I currently have no personal interest in bindings, but I would love to target TypeScript directly using similar code transformation as I did for ES5. However it will require non-trivial efforts which I as of yet have not planned. |
Hi, |
@HareIM doesn't https://turfjs.org/docs/#nearestPointOnLine do what you are asking for? |
Reading the docs and finding out that you had a typo when you run the code you copied poorly is not the same as having typescript guard you when you write the code. :-) |
Yes typescript is a life saver, sadly jsts is unusable in a typescript environment without correct typings. |
It's definitely doable, but I still have no pressing need myself. |
Hi Bjorn, Here is a guide how to generate: https://dev.to/jor/jsdoc-to-typescript-declaration-19fg In the cesiumjs code you can check the source code with the jsdoc tags: https://github.com/CesiumGS/cesium |
@PauloSSAragao that implies correct jsdoc transpiled from JavaDoc, which I believe is about as difficult to transpile to as TypeScript and less verifiable. |
@bjornharrtell I would find it interesting to investigate what would be needed in order to automatically generate typescript code from the java jts code. Would this be appreciated for this project? If so I would read into the bundler code and see how it could be modified to generate typescript as I don't see any library that could do this natively. |
@simonseyock JSTS was made by transpiling patched Java upstream code (JTS) to JavaScript with use of my own custom transpiler which can be found at https://github.com/bjornharrtell/java2estree made in Scala. It's pretty hacky stuff, so be warned. But it should be possible to hack it some more to output TypeScript instead. But it is no trivial task and requires Scala knowledge. I still have some interest in this and would welcome efforts.. my own priorities do not allow a large investment at this time. |
Ok, I might have some time at hands in the near future and will start looking into this. I do not know Scala, but I worked with functional programming languages before and also other languages on the java VM. So it might be interesting to try it out.. |
I've had some fun modernizing https://github.com/bjornharrtell/java2estree a bit.. and realized there is a problem with regard to this issue. The way java2estree works is by generating AST in estree format which is then transformed to JavaScript using a third party tool called astring. For TypeScript this will be have to be replaced by something equivalent and I'm not even sure that exists. |
You dont need to translate the whole library, only make the types documents that describe objects, return types and methods ..etc.. This is enough to include the js lib and use it in typescript Given that Java is type strong, you only need to scratch the surface.. Creating a library scraper shouldnt be too hard a challenge for a seasoned programmer |
@Montago you are saying that a viable path is to generate typescript type definitions directly from Java using some entirely other means of translation vs. the source to source translation? I think you underestimate what would be required to do so and get a result that is corresponding to the source to source translation. |
Hmm looks like there is some kind of more or less official TypeScript AST and the TypeScript compiler can turn that into code (see https://stackoverflow.com/questions/65213952/how-to-generate-code-from-ast-typescript-parser). Looks pretty promising actually! |
Food for thought, typescript-eslint/typescript-eslint#7228. |
If the typescript compiler can be used, that is definitely the way to go. |
There are some type definitions available on DefinitelyTyped, but they're woefully incomplete (they only cover
jsts.geom
and parts ofjsts.io
). An official set of type definitions would be a big usability win for TypeScript users and a documentation win for everyone.The text was updated successfully, but these errors were encountered: