cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.46k stars 160 forks source link

Where are the React candies? #59

Closed sykesd closed 8 years ago

sykesd commented 8 years ago

There are DefinitelyTyped definitions for Facebook's React library, but I don't see any candies for it.

Is there some technical reason that these don't exist?

renaudpawlak commented 8 years ago

There are around 25% of DefinitelyTyped definition that don't manage to get translated automatically (yet) by our API translator. This can be for various reasons. I will look into react more specifically ASAP.

sykesd commented 8 years ago

Thanks for the prompt response. And thanks for looking into it. Looking forward to it working

peisenmann commented 8 years ago

Any news on this?

pedjapesic commented 8 years ago

I am also looking forward to see this working

renaudpawlak commented 8 years ago

Oops. Thank you for reminding me. I also have other candies such as Polymer to look at... so I will make a pass ASAP.

renaudpawlak commented 8 years ago

Related to #102.

renaudpawlak commented 8 years ago

Just a quick update on this issue to let you know what is happening.

React definitions are significantly more complex than most average API definitions. Additionally, React is very active and uses the latest TypeScript improvements.

Currently I have updated our TypeScript definition parser to support some syntax that is used in react.d.ts (for instance JSweet's API translator now supports type parameters in type macros such as type Ref<T> = string | ((instance: T) => any)). I have also improved our translator to support a case of interface merging that was not supported yet.

So, all that being done, there are only two or three translation errors remaining, mostly due to generics issues. These are the most complicated issues to solve because the Java generics are much less flexible than TypeScript ones (because of type erasure). However, JSweet already supports a lot of cases so I am confident that I will find a solution for these ones too.

Since there are a lot of important things to be done before, I hope to find the time to solve the last problems last week. The good news is that, in the end, supporting React will help supporting other tricky libs :D

markjvickers commented 8 years ago

Still in progress?

renaudpawlak commented 8 years ago

Yes... did not have a chance to allocated enough time yet but I will switch back to it ASAP. Sorry about the delay but a lot of things on my plate these days!

renaudpawlak commented 8 years ago

I have made some progress. There is a first set of candies available in the repo but don't even try to use them, they won't work and are still in pretty bad shape!

I am confident that the core react API will eventually work, but now that I have to get familiar a little bit with React, I am asking myself a question: does it make sense to have react without the JSX syntax?

Well, first things first I guess... ;)

joelhandwell commented 8 years ago

@renaudpawlak this thread can give us some idea on how to deal with JSX.

joelhandwell commented 8 years ago

Will https://github.com/cincheo/jsweet/commit/891f194504315199ce4a9c1dddd48c37ccd5b22c enough to close this issue?

renaudpawlak commented 8 years ago

Actually I think so yes! I have tested basic examples and it seems to work well enough for a first version of it. Of course, there are various little details (like any new thing), but I am quite happy with it. Even without JSX, I think that it is neat and the examples that I have ported to JSweet are quite impressive.

I am planning to publish the few examples I have made to test react on github so that you get a playground to get started easily.

I'll tell you when it's done and I will close this issue afterwards.

renaudpawlak commented 8 years ago

I am happy to share this with you: https://github.com/cincheo/jsweet-examples-react You'll find the react candy in the repo now... it is called react-global. It is not perfect, but that's a start.

renaudpawlak commented 8 years ago

@joelhandwell your pointer for supporting JSX in Java seems promising, thanks. I first need to switch back on Angular 2... maybe someone will want to look at it in the meantime ;)