Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid IIFE for single-expression class static blocks (#14275)
- Loading branch information
1 parent
8b69dae
commit 1937284
Showing
50 changed files
with
122 additions
and
286 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
4 changes: 1 addition & 3 deletions
4
...ugin-proposal-class-static-block/test/fixtures/class-static-block/class-binding/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,8 +1,6 @@ | ||
class Foo { | ||
static bar = 42; | ||
static #_ = (() => { | ||
this.foo = Foo.bar; | ||
})(); | ||
static #_ = this.foo = Foo.bar; | ||
} | ||
|
||
expect(Foo.foo).toBe(42); |
4 changes: 1 addition & 3 deletions
4
...-proposal-class-static-block/test/fixtures/class-static-block/class-declaration/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,8 +1,6 @@ | ||
class Foo { | ||
static bar = 42; | ||
static #_ = (() => { | ||
this.foo = this.bar; | ||
})(); | ||
static #_ = this.foo = this.bar; | ||
} | ||
|
||
expect(Foo.foo).toBe(42); |
12 changes: 3 additions & 9 deletions
12
...-proposal-class-static-block/test/fixtures/class-static-block/in-class-heritage/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,15 +1,9 @@ | ||
class Foo extends class extends class Base { | ||
static #_ = (() => { | ||
this.qux = 21; | ||
})(); | ||
static #_ = this.qux = 21; | ||
} { | ||
static #_ = (() => { | ||
this.bar = 21; | ||
})(); | ||
static #_ = this.bar = 21; | ||
} { | ||
static #_ = (() => { | ||
this.foo = this.bar + this.qux; | ||
})(); | ||
static #_ = this.foo = this.bar + this.qux; | ||
} | ||
|
||
expect(Foo.foo).toBe(42); |
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
4 changes: 1 addition & 3 deletions
4
...ugin-proposal-class-static-block/test/fixtures/class-static-block/name-conflict/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,9 +1,7 @@ | ||
class Foo { | ||
static #_ = 42; // static block can not be tranformed as `#_` here | ||
|
||
static #_2 = (() => { | ||
this.foo = this.#_; | ||
})(); | ||
static #_2 = this.foo = this.#_; | ||
} | ||
|
||
expect(Foo.foo).toBe(42); |
4 changes: 1 addition & 3 deletions
4
...-plugin-proposal-class-static-block/test/fixtures/class-static-block/new-target/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
6 changes: 1 addition & 5 deletions
6
...lugin-proposal-class-static-block/test/fixtures/integration-loose/class-binding/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,9 +1,5 @@ | ||
class Foo {} | ||
|
||
Foo.bar = 42; | ||
|
||
(() => { | ||
Foo.foo = Foo.bar; | ||
})(); | ||
|
||
Foo.foo = Foo.bar; | ||
expect(Foo.foo).toBe(42); |
6 changes: 1 addition & 5 deletions
6
...n-proposal-class-static-block/test/fixtures/integration-loose/class-declaration/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,9 +1,5 @@ | ||
class Foo {} | ||
|
||
Foo.bar = 42; | ||
|
||
(() => { | ||
Foo.foo = Foo.bar; | ||
})(); | ||
|
||
Foo.foo = Foo.bar; | ||
expect(Foo.foo).toBe(42); |
11 changes: 2 additions & 9 deletions
11
...n-proposal-class-static-block/test/fixtures/integration-loose/in-class-heritage/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,13 +1,6 @@ | ||
var _class, _class2; | ||
|
||
class Foo extends (_class = class extends (_class2 = class Base {}, (() => { | ||
_class2.qux = 21; | ||
})(), _class2) {}, (() => { | ||
_class.bar = 21; | ||
})(), _class) {} | ||
|
||
(() => { | ||
Foo.foo = Foo.bar + Foo.qux; | ||
})(); | ||
class Foo extends (_class = class extends (_class2 = class Base {}, _class2.qux = 21, _class2) {}, _class.bar = 21, _class) {} | ||
|
||
Foo.foo = Foo.bar + Foo.qux; | ||
expect(Foo.foo).toBe(42); |
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 |
---|---|---|
|
@@ -13,7 +13,4 @@ Object.defineProperty(Foo, _bar, { | |
})(); | ||
|
||
Foo.qux = 21; | ||
|
||
(() => { | ||
Foo.qux2 = Foo.qux; | ||
})(); | ||
Foo.qux2 = Foo.qux; |
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: 2 additions & 8 deletions
10
...-proposal-class-static-block/test/fixtures/integration-loose/super-static-block/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,13 +1,7 @@ | ||
var _ref, _class; | ||
|
||
class Foo extends (_ref = (_class = class _ref {}, (() => { | ||
_class.bar = 42; | ||
})(), _class)) {} | ||
class Foo extends (_ref = (_class = class _ref {}, _class.bar = 42, _class)) {} | ||
|
||
Foo.bar = 21; | ||
|
||
(() => { | ||
Foo.foo = _ref.bar; | ||
})(); | ||
|
||
Foo.foo = _ref.bar; | ||
expect(Foo.foo).toBe(42); |
6 changes: 1 addition & 5 deletions
6
...abel-plugin-proposal-class-static-block/test/fixtures/integration/class-binding/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,9 +1,5 @@ | ||
class Foo {} | ||
|
||
babelHelpers.defineProperty(Foo, "bar", 42); | ||
|
||
(() => { | ||
Foo.foo = Foo.bar; | ||
})(); | ||
|
||
Foo.foo = Foo.bar; | ||
expect(Foo.foo).toBe(42); |
6 changes: 1 addition & 5 deletions
6
...-plugin-proposal-class-static-block/test/fixtures/integration/class-declaration/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,9 +1,5 @@ | ||
class Foo {} | ||
|
||
babelHelpers.defineProperty(Foo, "bar", 42); | ||
|
||
(() => { | ||
Foo.foo = Foo.bar; | ||
})(); | ||
|
||
Foo.foo = Foo.bar; | ||
expect(Foo.foo).toBe(42); |
11 changes: 2 additions & 9 deletions
11
...-plugin-proposal-class-static-block/test/fixtures/integration/in-class-heritage/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,13 +1,6 @@ | ||
var _class, _class2; | ||
|
||
class Foo extends (_class = class extends (_class2 = class Base {}, (() => { | ||
_class2.qux = 21; | ||
})(), _class2) {}, (() => { | ||
_class.bar = 21; | ||
})(), _class) {} | ||
|
||
(() => { | ||
Foo.foo = Foo.bar + Foo.qux; | ||
})(); | ||
class Foo extends (_class = class extends (_class2 = class Base {}, _class2.qux = 21, _class2) {}, _class.bar = 21, _class) {} | ||
|
||
Foo.foo = Foo.bar + Foo.qux; | ||
expect(Foo.foo).toBe(42); |
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
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
Oops, something went wrong.