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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage 3 allow decorators to generate PJOs #505

Closed
Giwayume opened this issue Mar 25, 2023 · 1 comment
Closed

Stage 3 allow decorators to generate PJOs #505

Giwayume opened this issue Mar 25, 2023 · 1 comment

Comments

@Giwayume
Copy link

Restricting decorators to only generate classes is causing unnecessary limitations for library authors. Example:

facing-dev/vue-facing-decorator#44

Please don't follow in the footsteps of Chrome team making everything class dependent, and creating a mess of a developer community that doesn't agree with these decisions:

WICG/webcomponents#587 (comment)

@pzuraq
Copy link
Collaborator

pzuraq commented Mar 25, 2023

Decorators on POJOs were originally considered as part of this proposal early on, along with decorators on functions and function parameters. However, these additional features increased the scope of the proposal, and were part of the reason that it has taken > 5 years to advance to stage 3. Getting consensus on the design of all of the different types of decorators that we could add to the language, all at once, would likely stall this proposal for additional years.

Much like classes, which were designed in phases with more features added over time (e.g. class fields, private fields, static blocks), the plan with decorators is to continue to add more types over time. Class decorators were chosen to start with because it is currently not possible to metaprogram with class elements like methods and fields. You can use the decoration pattern with POJOs today, though it is less ergonomic and readable, to be sure.

Given this history and context, POJO decorators will not be added to this proposal. It will continue to be tightly scoped to class and class element decorators. Additionally, since the proposal is now at stage 3, it would not be possible to expand the scope so much (at least not without potentially moving back to stage 2).

That said, this proposal does not prevent us from adding POJO decorators in the future, and I think it's likely that they will be explored at some point in a future proposal.

@pzuraq pzuraq closed this as completed Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants