Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use private static field initializer
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
- Loading branch information
1 parent
ca389fb
commit 8523873
Showing
19 changed files
with
68 additions
and
116 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
7 changes: 7 additions & 0 deletions
7
...plugin-proposal-class-static-block/test/fixtures/class-static-block/class-binding/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,7 @@ | ||
class Foo { | ||
static { | ||
this.foo = Foo.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
3 changes: 2 additions & 1 deletion
3
...in-proposal-class-static-block/test/fixtures/class-static-block/class-declaration/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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
class Foo { | ||
static { | ||
this.foo = 42; | ||
this.foo = this.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
3 changes: 2 additions & 1 deletion
3
...n-proposal-class-static-block/test/fixtures/class-static-block/class-declaration/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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
class Foo { | ||
static { | ||
this.foo = 42; | ||
this.foo = this.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
14 changes: 6 additions & 8 deletions
14
...-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,10 +1,8 @@ | ||
let Foo; | ||
Foo = class Foo { | ||
static _init() { | ||
this.foo = 42; | ||
delete this._init; | ||
return this; | ||
} | ||
class Foo { | ||
static bar = 42; | ||
static #_ = (() => { | ||
this.foo = this.bar; | ||
})(); | ||
} | ||
|
||
}._init(); | ||
expect(Foo.foo).toBe(42); |
3 changes: 0 additions & 3 deletions
3
...roposal-class-static-block/test/fixtures/class-static-block/class-expression/options.json
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...posal-class-static-block/test/fixtures/class-static-block/in-class-heritage-named/exec.js
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...osal-class-static-block/test/fixtures/class-static-block/in-class-heritage-named/input.js
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
...sal-class-static-block/test/fixtures/class-static-block/in-class-heritage-named/output.js
This file was deleted.
Oops, something went wrong.
8 changes: 6 additions & 2 deletions
8
...in-proposal-class-static-block/test/fixtures/class-static-block/in-class-heritage/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 |
---|---|---|
@@ -1,10 +1,14 @@ | ||
class Foo extends class { | ||
class Foo extends class extends class Base { | ||
static { | ||
this.qux = 21; | ||
} | ||
} { | ||
static { | ||
this.bar = 21; | ||
} | ||
} { | ||
static { | ||
this.foo = 2 * this.bar; | ||
this.foo = this.bar + this.qux; | ||
} | ||
} | ||
expect(Foo.foo).toBe(42); |
8 changes: 6 additions & 2 deletions
8
...n-proposal-class-static-block/test/fixtures/class-static-block/in-class-heritage/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 |
---|---|---|
@@ -1,10 +1,14 @@ | ||
class Foo extends class { | ||
class Foo extends class extends class Base { | ||
static { | ||
this.qux = 21; | ||
} | ||
} { | ||
static { | ||
this.bar = 21; | ||
} | ||
} { | ||
static { | ||
this.foo = 2 * this.bar; | ||
this.foo = this.bar + this.qux; | ||
} | ||
} | ||
expect(Foo.foo).toBe(42); |
26 changes: 12 additions & 14 deletions
26
...-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,17 +1,15 @@ | ||
let Foo; | ||
Foo = class Foo extends class { | ||
static _init2() { | ||
class Foo extends class extends class Base { | ||
static #_3 = (() => { | ||
this.qux = 21; | ||
})(); | ||
} { | ||
static #_2 = (() => { | ||
this.bar = 21; | ||
delete this._init2; | ||
return this; | ||
} | ||
})(); | ||
} { | ||
static #_ = (() => { | ||
this.foo = this.bar + this.qux; | ||
})(); | ||
} | ||
|
||
}._init2() { | ||
static _init() { | ||
this.foo = 2 * this.bar; | ||
delete this._init; | ||
return this; | ||
} | ||
|
||
}._init(); | ||
expect(Foo.foo).toBe(42); |
8 changes: 8 additions & 0 deletions
8
...-class-static-block/test/fixtures/class-static-block/multiple-static-initializers/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,8 @@ | ||
class Foo { | ||
static #bar = 21; | ||
static { | ||
this.foo = this.#bar + this.qux; | ||
} | ||
static qux = 21; | ||
} | ||
expect(Foo.foo).toBe(42); |
File renamed without changes.
11 changes: 4 additions & 7 deletions
11
...lugin-proposal-class-static-block/test/fixtures/class-static-block/super-property/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 |
---|---|---|
@@ -1,11 +1,8 @@ | ||
class Foo extends class { | ||
class Foo { | ||
static #_ = 42; | ||
// static block can not be tranformed as `#_` here | ||
static { | ||
this.bar = 42; | ||
} | ||
} { | ||
static bar = 21; | ||
static { | ||
this.foo = super.bar; | ||
this.foo = this.#_; | ||
} | ||
} | ||
expect(Foo.foo).toBe(42); |
3 changes: 0 additions & 3 deletions
3
...-proposal-class-static-block/test/fixtures/class-static-block/super-property/options.json
This file was deleted.
Oops, something went wrong.
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