Closed brundonsmith closed 4 years ago
Hi, I think it's possible to generate TypeScript type declarations as Haxe is a statically typed language. But I'm not sure if I can implement it (I'm not very familiar with TypeScript, and maybe heavy usage of macro is required), so any contributions would be greatly appreciated.
I'm familiar with TypeScript but I'd never even heard of Haxe until very recently, so I'm afraid I would be useless at trying to create macros for it, but I can certainly give advisement on the TS side.
As a workaround for my own project, I actually wrote a little script that does a decent job scraping type info from the documentation web pages. It would be hacky, but I could probably polish it up into a more complete, fully-automated tool. Sounds like that could be much easier than trying to do this the "right" way.
TypeScript can compile to Wasm with AssemblyScript. But it's new, requires the code to be written with a TypeScript subset and may have another limitations.
The SIMD in browsers is coming again through Wasm, it would be great if Oimo could compile to Wasm, probably beating Bullet performance in browsers.
@fabiodr I think you misunderstand. Oimo is written in Haxe, not JavaScript. It is compiled in this case from Haxe (a typed language) to plain JavaScript (an untyped language). My interest was in preserving the Haxe type info in the form of TypeScript declaration files (.d.ts
) to be shipped optionally alongside the actual .js
build, for those who are using it in a TypeScript context.
@brundonsmith sorry, i didn’t make my thoughts clear, it’s very nice to have type definitions but i was just wandering it would be great if Oimo could be ported to a language with Wasm as compilation target, i believe C++ or Rust are a better choices now but TypeScript is also becoming a good one, with clear syntax and more similar to Haxe :)
Maybe this project can help to do a small convert test project, it separates the generated javascript files and create typescript declarations. But probably won’t behave well with Oimo macros.
I checked before if Haxe has Wasm target but unfortunately i found only an integration to do Wasm calls without overhead and there is no roadmap for Wasm compilation yet.
One more side-note: Oimo.js is much better known than original Oimo and this last and improved version, because it is ported to JS, a language that engage more people on the web.
TypeScript also would invite more people to try and collaborate, giving Oimo the attention it deserves.
I tried Oimo.js; it's incomplete, the API is not as good, and as far as I can tell it's no longer being maintained. I made a feature request and the developer pointed me back to this repository.
Yeah, Oimo.js is based on an old Oimo ActionScript version (which can be found in this repo), this new Haxe version has a lot of improvements, including many joints, precision and performance.
@brundonsmith We are on the finish line with TS declarations, so I will keep everybody here posted
I'm sorry for leaving this issue for a long time, and thank you for your all efforts!
I've been trying to use hxtsdgen, but it doesn't seem to be
straightforward; hxtsdgen uses @:expose
notations to detect types to
declare, but OimoPhysics doesn't use @:expose
to export the classes (I
don't remember clearly, but there were some problems using expose
notation I guess).
I think it's preferable to generate TS declarations automatically, so I would switch to use @:expose
notations in future versions.
@saharan @brundonsmith If you could like this pull request: https://github.com/elsassph/hxtsdgen/pull/35
Hi. I've noticed the API documentation includes type info. I've only recently become aware of Haxe, so I don't know if that type info is part of the language or not, but would it be feasible to generate TypeScript type declarations from it when building to javascript? If not, I'm inclined to try and write some manually. In case you aren't familiar:
https://www.typescriptlang.org/docs/handbook/declaration-files/by-example.html#classes