-
-
Notifications
You must be signed in to change notification settings - Fork 75
Milestone: Decorator Support #63
Comments
Agreed. It's probably worth looking at the AST that Babel produces for decorators, which I'm guessing is similar. |
Good thinking! astexplorer shows that babel-eslint produces near identical output, with both the decorator and decorator factory nodes (within a As described above, the Here is a PR #64 for a Parameter Decorator and a Parameter Decorator Factory on an instance method to get the ball rolling and confirm the format with you. Feel free to leave it open until more cases are added, but I need to break off now as it's quite late here. |
Makes sense. Bonus points for the animated demo. :) |
It looks like Flow does support decorators, and it's with the |
Ok, cool thanks. Do you have a reference for that you can link to? I will update that first PR now |
I just used astexplorer.net. |
Method decorator support (static and instance methods) now complete in #64 |
Class decorator support now also complete. I branched from the method decorator PR to avoid conflicts. PR is here #67 |
It appears that flow does not currently support Parameter Decorators. I think it makes sense to just follow the same approach as with the other decorator types - a |
Agreed. |
Cool, thanks. In which case PR for parameter decorators is ready #69 |
Property decorators up next! #72 |
You are rocking! |
🎸 |
@JamesHenry you are awesome. Thanks for all your work on this. |
Thanks so much @nzakas! Your patience and guidance has been invaluable throughout this process |
This issue it to track progress against supporting decorators within the final AST that the parser produces. We currently remove them during parsing.
We need to ensure that the following are accurately carried over from the original TypeScript AST:
We also need to account for the difference between decorators and decorator factories:
Decorator:

Decorator Factory:

At the AST-level, the decorator node has an
Identifier
TSNode as anexpression
, whereas the decorator factory has aCallExpression
TSNode.Decorators are not currently covered by the ESTree spec as they are still a fairly early-stage es-proposal, but Angular 2, for example, has adopted them as a core aspect of the framework.
TypeScript adds a
decorators
array to the node in question, and I propose we do the same.Resources:
https://www.typescriptlang.org/docs/handbook/decorators.html
The text was updated successfully, but these errors were encountered: