-
Notifications
You must be signed in to change notification settings - Fork 158
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
Proposal for decorator support #43
Comments
Important point, for sure. What do you think about (1) check that the decorator function exists (2) annotate with Ambient in candies and local declarations? Thanks. |
Please, any progress with decorators? I really want to get started with Angular 2 and beloved JSweet |
Well... there has been more demand on React, so I did it first. But I am really impatient to make Angular 2 to work! Now that React works, Angular 2 will probably be one of the next things to be done. I'll keep you updated. |
Wow, thanks for the prompt response. Will delay our project and focus on Good job.
|
@renaudpawlak, I'm doing a JavaOne presentation on JSweet and I was hoping to use it with Angular2. What's the status of this? Are there any other barriers to Angular2 support? |
Hi. Excellent initiative! Well, AFAIK, this is the only barrier (but I cannot be sure until annotations are supported). Actually, all boils down to the core barrier: having more time ;) |
Thanks for the quick response, @renaudpawlak. Well, my presentation is in exactly two weeks, so ASAP :-). Here is a link: https://oracle.rainfocus.com/scripts/catalog/oow16.jsp?event=javaone&search=jsweet&search.event=javaone. I realize that's a very short time frame, so it may be better to shoot for December. I'm giving the same presentation again (although probably to a much smaller audience): https://live360events.com/Events/Orlando-2016/Sessions/Tuesday/ADT06-Full-Stack-Java-with-JSweet-Angular-2-PrimeNG-and-JAXRS.aspx. If Angular2 support isn't possible with JSweet, I'll probably change the JavaOne session to just use TypeScript on the front-end. |
I will give it a first try today (I have just finished something and I have a free slot)... we will see how it goes... maybe it will go very smoothly. I'll keep in touch. |
Ok! I have good news. I managed to create an Angular 2 quickstart with JSweet. That's cool :) So, I have a first support of decorators, only for types. It follows this proposal. It will be extended to variables, functions, and parameter decorators, but the most important for Angular 2 is done. One really cool thing about this project is that JSweet just converts to TypeScript and tsc takes care of the TS to JS conversion (there is a new option All the details on how to use in the project: https://github.com/cincheo/jsweet-angular2-quickstart Please tell me if this is a good start for you or if something is missing or unclear. I hope you will enjoy it as much as I enjoyed making Angular 2 work with JSweet ;) |
Wow! Thanks so much, @renaudpawlak! So far it looks great, but I'll take a deeper look at it tomorrow! After we get through the Angular stuff, we can talk about PolymerTS ;-). |
Haha, actually we already got this one running ;) take a look at: |
@kito99 do you need anything else for your presentation? Don't hesitate to tell me if anything is unclear or if you hit any issue. |
Thanks for pointing that out, @lgrignon. I'll have to take a closer look when I get a chance. I'm using PolymerTS on currently, so I'd love to see the same support for annotations/decorators ;-). |
@renaudpawlak, I just got it working locally. I had to add the repositories to pom.xml:
I also had to run So far, so good! |
Grrr. I always forget the repos. Thank you for reporting. I have just pushed them. |
@renaudpawlak, how hard would it be to create a candy for PrimeNG (https://github.com/primefaces/primeng)? |
I'll start leaving issues/questions in the angular2-starter project. I've already found a few things. |
I have just created a quickstart project to show how to create candies from an existing JS lib: https://github.com/cincheo/jsweet-candy-js-quickstart As you can see, it is pretty straightforward, and I don't see any limitations to the approach (can be used to write a primeng candy)... but I still need to document better how to write definitions with JSweet. @kito99 please do ask your questions. Maybe you want to share an example project and maybe we could build a first angular 2 candy for the occasion. Don't hesitate to use my private email when it gets too much into the details. |
Is there something changed with decorator support or am I doing something wrong? The transpiler makes the references to annotations right but it does not compile the actual annotation ts-classes at all. With the latest transpiler I qet error like: |
Current snapshot (2.0.0-SNAPSHOT) supports class, method, and field decorators. See the related test to see what is supported exactly. If it does not work as in the test, it might be a configuration issue (or an edge-case bug). |
Okey. Your example helped me forward. Thanks! It seems that the decorator can not be defined on separate file. If I add all decorations to same java file where the Globals are defined it works. I don't know yet very well how JSweet works from inside, but I can guess there is a natural explanation why it works like this. |
We need to support decorators: microsoft/TypeScript#2249
To support decorators, I propose a meta annotation @decorator.
For instance (this is still approximate code):
Would transpile to (approximate code also):
This this just a proposal that needs to be refined. In particular, the definition of the global decoration methods could be improved and the overall pattern needs to be validated.
The text was updated successfully, but these errors were encountered: