vert-x3 / vertx-lang-js

Nashorn JavaScript implementation for Vert.x
Apache License 2.0
35 stars 23 forks source link

TypeScript support could generate Enums instead of string ? #75

Open vorburger opened 6 years ago

vorburger commented 6 years ago

E.g. here I've written for https://github.com/vorburger/minecraft-storeys-maker/issues/76 a @ProxyGen using Java enum (in that example both for an argument, see HandType; as well as for the return type, see ItemType) like this:

void getItemHeld(String code, HandType hand, Handler<AsyncResult<ItemType>> handler);

and in the generated TypeScript signature (in minecraft-storeys-maker/api/build/classes/java/main/Minecraft-ts/minecraft-proxy.ts) this turned into:

  getItemHeld(code: string, hand: string, handler: (err: any, result: any) => any) : void {

where, in an ideal world, it could be more "strongly typed" with a TypeScript enum :

  getItemHeld(code: string, hand: HandType, handler: (err: any, result: ItemType) => any) : void {   

@edewit FYI.

vorburger commented 6 years ago

@pmlopes I hope that this is the right place to file this RFE idea?

pmlopes commented 6 years ago

I think the "next" step would be to follow the same approach https://github.com/reactiverse/es4x is using, by generating the proper JavaScript bindings and correct typescript definitions (which include enums)

That would allow the usage from both JS or TS and generation of proper documentation like this one for example: https://reactiverse.io/es4x/@vertx/core/index.html (where you can see both the types and docs extracted from the underlying interfaces).