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
Convert private methods to fields when they are supported #12250
Closed
nicolo-ribaudo
wants to merge
14
commits into
babel:nicolo-ribaudo/targets-in-core
from
nicolo-ribaudo:private-to-field-when-supported
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3ad1852
Compile private methods to private fields for modern targets
nicolo-ribaudo ecab33d
Refine feature checks in helper-create-class-features-plugin
nicolo-ribaudo 4884d06
Better interop when modern targets and forced class properties plugin
nicolo-ribaudo f88d197
More tests
nicolo-ribaudo 8899171
preset-env integration
nicolo-ribaudo fda3fa7
Only test on Node.js ^12
nicolo-ribaudo 7b421f9
Review
nicolo-ribaudo b0e0fff
Use environmentVisitor
nicolo-ribaudo 9ff103c
Computed keys are in the outer scope
nicolo-ribaudo 020ba5d
Update after rebase
nicolo-ribaudo 6d522fe
Update test
nicolo-ribaudo 7804497
Smaller output for accessors
nicolo-ribaudo 63ccea0
Remove api.targets existence check
nicolo-ribaudo 6a18821
Review
nicolo-ribaudo File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...features-plugin/test/fixtures/plugin-proposal-class-properties/no-compile-method/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class B { | ||
foo = 2; | ||
|
||
#bar() {}; | ||
} |
8 changes: 8 additions & 0 deletions
8
...ures-plugin/test/fixtures/plugin-proposal-class-properties/no-compile-method/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"plugins": [ | ||
["external-helpers", { "helperVersion": "7.100.0" }], | ||
"syntax-class-properties", | ||
"proposal-class-properties" | ||
], | ||
"throws": "Class private methods are not enabled.\nYou can enable @babel/plugin-proposal-private-methods to compile them." | ||
} |
11 changes: 11 additions & 0 deletions
11
...class-features-plugin/test/fixtures/plugin-proposal-decorators/no-compile-fields/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class B { | ||
#foo = 1; | ||
bar = 2; | ||
} | ||
|
||
class A { | ||
@deco | ||
foo() {} | ||
|
||
bar = 2; | ||
} |
7 changes: 7 additions & 0 deletions
7
...s-features-plugin/test/fixtures/plugin-proposal-decorators/no-compile-fields/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"plugins": [ | ||
["external-helpers", { "helperVersion": "7.100.0" }], | ||
["proposal-decorators", { "decoratorsBeforeExport": true }], | ||
["syntax-class-properties"] | ||
] | ||
} |
33 changes: 33 additions & 0 deletions
33
...lass-features-plugin/test/fixtures/plugin-proposal-decorators/no-compile-fields/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class B { | ||
#foo = 1; | ||
bar = 2; | ||
} | ||
|
||
let A = babelHelpers.decorate(null, function (_initialize) { | ||
"use strict"; | ||
|
||
class A { | ||
constructor() { | ||
_initialize(this); | ||
} | ||
|
||
} | ||
|
||
return { | ||
F: A, | ||
d: [{ | ||
kind: "method", | ||
decorators: [deco], | ||
key: "foo", | ||
value: function foo() {} | ||
}, { | ||
kind: "field", | ||
key: "bar", | ||
|
||
value() { | ||
return 2; | ||
} | ||
|
||
}] | ||
}; | ||
}); |
8 changes: 8 additions & 0 deletions
8
...features-plugin/test/fixtures/plugin-proposal-decorators/private-different-class/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class A { | ||
@deco | ||
foo() {} | ||
} | ||
|
||
class B { | ||
#priv; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of feature (1): the first class is not transformed.