forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support computed class property names (babel#4499)
** Depends on babel/babylon#121 ** * `babel-types`: Add `computed` field to `ClassProperty` * `babel-plugin-transform-class-properties`: handle computed property names correctly * `babel-generator`: add tests for class properties (computed/literal, static/instance)
- Loading branch information
Showing
9 changed files
with
70 additions
and
5 deletions.
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
19 changes: 19 additions & 0 deletions
19
packages/babel-generator/test/fixtures/types/ClassBody-ClassProperty/actual.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,19 @@ | ||
class Foo { | ||
foo; | ||
foo = 1; | ||
"foo"; | ||
"foo" = 1; | ||
["foo"]; | ||
["foo"] = 1; | ||
["f" + "oo"]; | ||
["f" + "oo"] = 1; | ||
|
||
static foo; | ||
static foo = 1; | ||
static "foo"; | ||
static "foo" = 1; | ||
static ["foo"]; | ||
static ["foo"] = 1; | ||
static ["f" + "oo"]; | ||
static ["f" + "oo"] = 1; | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/babel-generator/test/fixtures/types/ClassBody-ClassProperty/expected.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,19 @@ | ||
class Foo { | ||
foo; | ||
foo = 1; | ||
"foo"; | ||
"foo" = 1; | ||
["foo"]; | ||
["foo"] = 1; | ||
["f" + "oo"]; | ||
["f" + "oo"] = 1; | ||
|
||
static foo; | ||
static foo = 1; | ||
static "foo"; | ||
static "foo" = 1; | ||
static ["foo"]; | ||
static ["foo"] = 1; | ||
static ["f" + "oo"]; | ||
static ["f" + "oo"] = 1; | ||
} |
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
3 changes: 3 additions & 0 deletions
3
...babel-plugin-transform-class-properties/test/fixtures/general/instance-computed/actual.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,3 @@ | ||
class Foo { | ||
[bar] = "foo"; | ||
} |
4 changes: 4 additions & 0 deletions
4
...bel-plugin-transform-class-properties/test/fixtures/general/instance-computed/expected.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,4 @@ | ||
var Foo = function Foo() { | ||
babelHelpers.classCallCheck(this, Foo); | ||
this[bar] = "foo"; | ||
}; |
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