Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] migrate our decorators to latest JS decorator spec #1180

Closed
3cp opened this issue Jun 4, 2021 · 6 comments 路 Fixed by #1932
Closed

[RFC] migrate our decorators to latest JS decorator spec #1180

3cp opened this issue Jun 4, 2021 · 6 comments 路 Fixed by #1932

Comments

@3cp
Copy link
Member

3cp commented Jun 4, 2021

馃挰 RFC

馃敠 Context

Our decorators are currently in outdated legacy decorator API format.

The result is we still need legacy mode when transpiling the code.

In Babel, it's [ "@babel/plugin-proposal-decorators", { "legacy": true } ].

In TypeScript, it's just "experimentalDecorators": true. TypeScript understands our decorators are in legacy mode because it knows the type definition of those decorators, so it smartly transpiling the code accordingly.

We probably need to switch our decorators to the APIs of latest spec. https://github.com/tc39/proposal-decorators
Then we can drop "legacy": true in babel config. The babel config will become [ "@babel/plugin-proposal-decorators", { "decoratorsBeforeExport": true } ] (For usability, we need that decoratorsBeforeExport to deviate from current spec, TypeScript silently supports that).

馃捇 Examples

@3cp 3cp changed the title [RFC] should we migrate our decorators to latest JS decorator spec [RFC] migrate our decorators to latest JS decorator spec Jun 4, 2021
@bigopon
Copy link
Member

bigopon commented Jun 4, 2021

Unless this proposal gets to stage 4, I think we should stay far away from it. I don't know how many hops we have to get through along the ride for a stage 2 proposal, especially this decorator one.

@Vheissu
Copy link
Member

Vheissu commented Jun 8, 2021

I agree this is very important @3cp but I agree with @bigopon that right now given how turbulent the decorator's specification has been and the fact they've been trying to get decorators to stage 3 for three years now, we should stick with legacy. As we can see in this linked section in the README, they are recommending that everyone sticks with the legacy decorators for the time being.

@3cp
Copy link
Member Author

3cp commented Jun 10, 2021

The state of decorator is so bad, if they can put decorator into ES spec, a lot of frameworks can use plain ESM code without transpiling.
It's insane to argue about the decorator design for so many years. It feels like no end.

@Vheissu
Copy link
Member

Vheissu commented Sep 6, 2022

@bigopon @3cp Given the decorator proposal has reached stage 3, are we more confident with the new design and migrating over?

@bigopon
Copy link
Member

bigopon commented Sep 6, 2022

it's a massive move, we probably want to delay it until the last moment. If we were to do it now, any small changes from now would cause a lot of headache.

@m-gallesio
Copy link

For reference, decorators are implemented in TypeScript 5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants