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

Support Flow's proto modifier syntax for declared classes #7978

Merged
merged 4 commits into from
May 25, 2018

Conversation

samwgoldman
Copy link
Contributor

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

See facebook/flow@eb815be for more information about this feature.

The proto modifier indicates that a property declared using x: T syntax is actually present on the prototype object of the class, rather than an own property.

The proto and static modifiers are mutually exclusive, as class declarations don't simultaneously define the static prototype object, as they do the instance prototype.

This syntax is only supported on declared classes, not object types, interfaces, or runtime class declarations, and as such should only appear in library definitions.

@samwgoldman samwgoldman changed the title Proto props Support Flow's proto modifier syntax for declared classes May 18, 2018
@babel-bot
Copy link
Collaborator

babel-bot commented May 18, 2018

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

@@ -321,6 +321,7 @@ defineType("ObjectTypeProperty", {
value: validateType("FlowType"),
kind: validate(assertOneOf("init", "get", "set")),
static: validate(assertValueType("boolean")),
proto: validate(assertValueType("proto")),
Copy link
Member

Choose a reason for hiding this comment

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

boolean?

Also, can we assert that the property isn't both statc and proto?

@existentialism existentialism added PR: New Feature 🚀 A type of pull request used for our changelog categories area: flow labels May 25, 2018
See
facebook/flow@eb815be
for more information about this feature.

The proto modifier indicates that a property declared using `x: T`
syntax is actually present on the prototype object of the class, rather
than an own property.

The proto and static modifiers are mutually exclusive, as class
declarations don't simultaneously define the static prototype object, as
they do the instance prototype.

This syntax is only supported on declared classes, not object
types, interfaces, or runtime class declarations, and as such should
only appear in library definitions.
@existentialism
Copy link
Member

Rebased, and updated to assert proto is boolean.

@nicolo-ribaudo we can probably just follow up with both an exclusive assertion util and updating the builder?

@existentialism existentialism merged commit f028357 into babel:master May 25, 2018
existentialism added a commit to prettier/prettier that referenced this pull request May 25, 2018
storyn26383 pushed a commit to UniSharp/babel that referenced this pull request Aug 6, 2018
<!--
Before making a PR please make sure to read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md

For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. It should be underlined in the preview if done correctly.
-->

| Q                        | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues?            | <!-- remove the (`) quotes to link the issues -->
| Patch: Bug Fix?          |
| Major: Breaking Change?  | No
| Minor: New Feature?      | Yes
| Tests Added + Pass?      | Yes
| Documentation PR         | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes?  |
| License                  | MIT

See facebook/flow@eb815be for more information about this feature.
    
The proto modifier indicates that a property declared using `x: T` syntax is actually present on the prototype object of the class, rather than an own property.
    
The proto and static modifiers are mutually exclusive, as class declarations don't simultaneously define the static prototype object, as they do the instance prototype.
    
This syntax is only supported on declared classes, not object types, interfaces, or runtime class declarations, and as such should only appear in library definitions.
@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
area: flow 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants