-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
More js-compatible classes and support for decorators #269
Comments
I think for now this is not something we want to consider for this project (yet). Like discussed in other issues we do not necessarily want to recreate exact JavaScript behavior. I am not convinced yet this added complexity is worth it. |
I don't think there's any simple way to implement decorators, even if some of it's specifics would be dropped. So it's either some complicated way constructing classes or not supporting decorators at all. |
I think you're overcomplicating this. Here's your example bellow. Note that I completely ignore the property descriptor from the signature - I don't think the complexity and the runtime cost of having things like non-enumerable properties is really worth it. The behavior bellow seems to be consistent to how typescript currently handles decorators.
now transpiles to
We just need it to transpile to
|
TypeScript (and most of decorator-related things in JS now) implements a stage-0 decorators proposal. After that it changed a lot. Of course these decorators may be implemented, but stage-2 decorators may progress to stage-3, so they would be implemented in TypeScript (now there's only Babel support). No idea how TS team would handle migration, but in the end someday they will have to remove legacy proposal anyway. |
Honestly, I have no idea how typescript will implement the stage-2 decorator proposal(and I don't fully understand the implications of it). It's not only a matter of migration(which would obviously be a pain), |
Sure, I'm not saying that old decorators shouldn't be implemented. I assume that typescript would use different option for new proposal, so both proposals may be supported independently. |
Closing because of recent changes in the proposal |
To implement decorator support classes should be constructed in the runtime
For more details and reasoning of using such a complex way to declare classes check out:
Doing makes generated code further from what you'd write in Lua, but makes it match JS behavior more and gives a chance to solve #229 and #256.
The text was updated successfully, but these errors were encountered: