Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract computed keys from the class closure
- Loading branch information
1 parent
1d48bb0
commit 7b31316
Showing
12 changed files
with
117 additions
and
29 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
10 changes: 5 additions & 5 deletions
10
packages/babel-plugin-transform-classes/test/fixtures/get-set/change-computed-key/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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
let A = /*#__PURE__*/function () { | ||
let A = /*#__PURE__*/function (_x, _ref, _x2) { | ||
"use strict"; | ||
|
||
function A() { | ||
babelHelpers.classCallCheck(this, A); | ||
} | ||
|
||
babelHelpers.createClass(A, [{ | ||
key: x, | ||
key: _x, | ||
get: function () {} | ||
}, { | ||
key: (x = 2, 3), | ||
key: _ref, | ||
value: function () {} | ||
}, { | ||
key: x, | ||
key: _x2, | ||
set: function (_) {} | ||
}]); | ||
return A; | ||
}(); | ||
}(x, (x = 2, 3), x); |
5 changes: 5 additions & 0 deletions
5
packages/babel-plugin-transform-classes/test/fixtures/spec/computed-key-class-tdz/exec.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 @@ | ||
expect(() => { | ||
class A { | ||
[A.name]() {} | ||
} | ||
}).toThrow(ReferenceError); |
4 changes: 4 additions & 0 deletions
4
...ges/babel-plugin-transform-classes/test/fixtures/spec/computed-key-class-tdz/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,4 @@ | ||
{ | ||
"plugins": ["transform-classes"], | ||
"minNodeVersion": "10.0.0" | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/babel-plugin-transform-classes/test/fixtures/spec/computed-keys-call-order/exec.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 @@ | ||
var log = []; | ||
|
||
class A { | ||
[log.push(1)]() {} | ||
static [log.push(2)]() {} | ||
[log.push(3)]() {} | ||
static [log.push(4)]() {} | ||
} | ||
|
||
expect(log).toEqual([1, 2, 3, 4]); | ||
|
9 changes: 9 additions & 0 deletions
9
...ages/babel-plugin-transform-classes/test/fixtures/spec/computed-keys-yield-await/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,9 @@ | ||
async function* fn() { | ||
class A { | ||
[yield 1]() {} | ||
} | ||
|
||
class B extends A { | ||
[await 1]() {} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ges/babel-plugin-transform-classes/test/fixtures/spec/computed-keys-yield-await/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,34 @@ | ||
async function* fn() { | ||
var A = /*#__PURE__*/function (_yield$) { | ||
"use strict"; | ||
|
||
function A() { | ||
babelHelpers.classCallCheck(this, A); | ||
} | ||
|
||
babelHelpers.createClass(A, [{ | ||
key: _yield$, | ||
value: function value() {} | ||
}]); | ||
return A; | ||
}(yield 1); | ||
|
||
var B = /*#__PURE__*/function (_A, _await$) { | ||
"use strict"; | ||
|
||
babelHelpers.inherits(B, _A); | ||
|
||
var _super = babelHelpers.createSuper(B); | ||
|
||
function B() { | ||
babelHelpers.classCallCheck(this, B); | ||
return _super.apply(this, arguments); | ||
} | ||
|
||
babelHelpers.createClass(B, [{ | ||
key: _await$, | ||
value: function value() {} | ||
}]); | ||
return B; | ||
}(A, await 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
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
8 changes: 4 additions & 4 deletions
8
packages/babel-plugin-transform-classes/test/fixtures/spec/relaxed-method-coercion/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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
// #1649 | ||
var Foo = /*#__PURE__*/function () { | ||
var Foo = /*#__PURE__*/function (_Symbol, _Symbol2) { | ||
"use strict"; | ||
|
||
function Foo() { | ||
babelHelpers.classCallCheck(this, Foo); | ||
} | ||
|
||
babelHelpers.createClass(Foo, [{ | ||
key: Symbol(), | ||
key: _Symbol, | ||
value: function value() {} | ||
}, { | ||
key: Symbol(), | ||
key: _Symbol2, | ||
value: function value() {} | ||
}]); | ||
return Foo; | ||
}(); | ||
}(Symbol(), Symbol()); |