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

[decorators] Add support for initializers #9008

Closed

Conversation

nicolo-ribaudo
Copy link
Member

tc39/proposal-decorators@cc2db18

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? yes
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@nicolo-ribaudo nicolo-ribaudo added the PR: New Feature 🚀 A type of pull request used for our changelog categories label Nov 9, 2018
@babel-bot
Copy link
Collaborator

babel-bot commented Nov 9, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/9681/

}
});

elements.forEach(function(element /*: ElementDescriptor */) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why two loops instead of combining the two?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Becose they differ both in the if condition and in the behavior inside the if.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that I misinterpreted your question 🙃

The proposal says that all methods must be defined before the fields/initializers. If I used a single loop, that order wouldn't be maintained.

Copy link

@littledan littledan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch looks great, both the implementation and the tests! I am glad to see that it still makes sense to follow along with the spec.

You may want to add tests that demonstrate the evaluation order of static finishers vs static initializers vs static fields, and own initializers vs own fields. But this is fine to do in a follow-on PR.

@rushjoe18
Copy link

Thanks

@littledan
Copy link

littledan commented Nov 15, 2018

The new test of ordering looks good to me. I'd say, this patch is ready to land, though note that we haven't discussed the feature in TC39 yet.

@nicolo-ribaudo
Copy link
Member Author

When is the next meeting? I can enable it using a flag in the meantime

@littledan
Copy link

November 27-29. Enabling with a flag SGTM, assuming there are no stability properties attached to the flag.

@xtuc xtuc mentioned this pull request Nov 15, 2018
6 tasks
@nicolo-ribaudo
Copy link
Member Author

We discussed this at the meeting today and decided to wait for the TC39 meeting, since we don't want to introduce a flag which we might deprecate in two weeks.

@nicolo-ribaudo nicolo-ribaudo added this to In progress in Class features Nov 21, 2018
@nicolo-ribaudo nicolo-ribaudo moved this from In progress to In Progress - Low priority in Class features Nov 21, 2018
@nicolo-ribaudo nicolo-ribaudo moved this from In Progress - Low priority to In progress in Class features Nov 21, 2018
@nicolo-ribaudo
Copy link
Member Author

@littledan What is the meeting outcome?

@nicolo-ribaudo
Copy link
Member Author

Blocked by tc39/proposal-decorators#182

@littledan
Copy link

@nicolo-ribaudo We seem to be in agreement about adding the feature, but a name bikeshed remains.

@nicolo-ribaudo
Copy link
Member Author

The feature is now enabled behind an option: ["@babel/plugin-proposal-decorators", { "initializers": true }], thanks to #9166. That way, if the name will change it will be easy to update Babel 😄

@nicolo-ribaudo nicolo-ribaudo moved this from Pending TC39 decision to Done in Class features Dec 29, 2018
@nicolo-ribaudo nicolo-ribaudo moved this from Done to In progress in Class features Dec 29, 2018
@nicolo-ribaudo
Copy link
Member Author

tc39/proposal-decorators#199 changed the name of initializers

@nicolo-ribaudo
Copy link
Member Author

I will open a different PR for "hooks"

@nicolo-ribaudo nicolo-ribaudo deleted the decorators-initializer branch January 16, 2019 22:42
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories Spec: Decorators
Projects
No open projects
Class features
  
In progress
Development

Successfully merging this pull request may close these issues.

None yet

5 participants