Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
special handling for classExpression
- Loading branch information
Showing
14 changed files
with
139 additions
and
24 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
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
23 changes: 23 additions & 0 deletions
23
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/8882/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,23 @@ | ||
const classes = []; | ||
for (let i = 0; i <= 10; ++i) { | ||
classes.push( | ||
class A { | ||
[i] = `computed field ${i}`; | ||
static foo = `static field ${i}`; | ||
#bar = `private field ${i}`; | ||
getBar() { | ||
return this.#bar; | ||
} | ||
} | ||
); | ||
} | ||
|
||
for(let i=0; i<= 10; ++i) { | ||
const clazz = classes[i]; | ||
expect(clazz.foo).toBe('static field ' + i); | ||
|
||
const instance = new clazz(); | ||
expect(Object.getOwnPropertyNames(instance)).toEqual([String(i)]) | ||
expect(instance[i]).toBe('computed field ' + i); | ||
expect(instance.getBar()).toBe('private field ' + i); | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/8882/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,13 @@ | ||
const classes = []; | ||
for (let i = 0; i <= 10; ++i) { | ||
classes.push( | ||
class A { | ||
[i] = `computed field ${i}`; | ||
static foo = `static field ${i}`; | ||
#bar = `private field ${i}`; | ||
getBar() { | ||
return this.#bar; | ||
} | ||
} | ||
); | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/8882/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,3 @@ | ||
{ | ||
"plugins": ["external-helpers", "proposal-class-properties"] | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/babel-plugin-proposal-class-properties/test/fixtures/regression/8882/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,32 @@ | ||
const classes = []; | ||
|
||
for (let i = 0; i <= 10; ++i) { | ||
var _class, _temp; | ||
|
||
classes.push(function () { | ||
var _ret; | ||
|
||
const _i = i; | ||
_temp = _class = class A { | ||
constructor() { | ||
babelHelpers.defineProperty(this, _i, `computed field ${i}`); | ||
|
||
_bar.set(this, { | ||
writable: true, | ||
value: `private field ${i}` | ||
}); | ||
} | ||
|
||
getBar() { | ||
return babelHelpers.classPrivateFieldGet(this, _bar); | ||
} | ||
|
||
}; | ||
|
||
var _bar = new WeakMap(); | ||
|
||
babelHelpers.defineProperty(_class, "foo", `static field ${i}`); | ||
_ret = _temp; | ||
return _ret; | ||
}()); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
.../babel-plugin-proposal-class-properties/test/fixtures/static-property-tdz/loose/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
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