Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not return stub initializer when empty
- Loading branch information
Showing
4 changed files
with
108 additions
and
14 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
51 changes: 51 additions & 0 deletions
51
...plugin-proposal-decorators/test/fixtures/2021-12-ordering--to-es2015/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,51 @@ | ||
var log = []; | ||
|
||
function push(x) { log.push(x); return x; } | ||
|
||
function logDecoratorRun(a, b, c) { | ||
push(a); | ||
return function (el, { addInitializer }) { | ||
push(b); | ||
addInitializer(function () { push(c); }); | ||
return el; | ||
}; | ||
} | ||
|
||
@logDecoratorRun(0, 35, 45) | ||
@logDecoratorRun(1, 34, 44) | ||
class A { | ||
@logDecoratorRun(2, 19) | ||
@logDecoratorRun(3, 18) | ||
a() {}; | ||
|
||
@logDecoratorRun(4, 21, 37) | ||
@logDecoratorRun(5, 20, 36) | ||
static b() {}; | ||
|
||
@logDecoratorRun(6, 23, 39) | ||
@logDecoratorRun(7, 22, 38) | ||
static #c() {}; | ||
|
||
@logDecoratorRun(8, 25) | ||
@logDecoratorRun(9, 24) | ||
#d() {}; | ||
|
||
@logDecoratorRun(10, 27) | ||
@logDecoratorRun(11, 26) | ||
accessor e; | ||
|
||
@logDecoratorRun(12, 29, 41) | ||
@logDecoratorRun(13, 28, 40) | ||
static accessor f; | ||
|
||
@logDecoratorRun(14, 31, 43) | ||
@logDecoratorRun(15, 30, 42) | ||
static accessor #g; | ||
|
||
@logDecoratorRun(16, 33) | ||
@logDecoratorRun(17, 32) | ||
accessor #h; | ||
} | ||
|
||
var nums = Array.from({ length: 46 }, (_, i) => i); | ||
expect(log).toEqual(nums); |
51 changes: 51 additions & 0 deletions
51
...ages/babel-plugin-proposal-decorators/test/fixtures/2021-12-ordering/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,51 @@ | ||
var log = []; | ||
|
||
function push(x) { log.push(x); return x; } | ||
|
||
function logDecoratorRun(a, b, c) { | ||
push(a); | ||
return function (el, { addInitializer }) { | ||
push(b); | ||
addInitializer(function () { push(c); }); | ||
return el; | ||
}; | ||
} | ||
|
||
@logDecoratorRun(0, 35, 45) | ||
@logDecoratorRun(1, 34, 44) | ||
class A { | ||
@logDecoratorRun(2, 19) | ||
@logDecoratorRun(3, 18) | ||
a() {}; | ||
|
||
@logDecoratorRun(4, 21, 37) | ||
@logDecoratorRun(5, 20, 36) | ||
static b() {}; | ||
|
||
@logDecoratorRun(6, 23, 39) | ||
@logDecoratorRun(7, 22, 38) | ||
static #c() {}; | ||
|
||
@logDecoratorRun(8, 25) | ||
@logDecoratorRun(9, 24) | ||
#d() {}; | ||
|
||
@logDecoratorRun(10, 27) | ||
@logDecoratorRun(11, 26) | ||
accessor e; | ||
|
||
@logDecoratorRun(12, 29, 41) | ||
@logDecoratorRun(13, 28, 40) | ||
static accessor f; | ||
|
||
@logDecoratorRun(14, 31, 43) | ||
@logDecoratorRun(15, 30, 42) | ||
static accessor #g; | ||
|
||
@logDecoratorRun(16, 33) | ||
@logDecoratorRun(17, 32) | ||
accessor #h; | ||
} | ||
|
||
var nums = Array.from({ length: 46 }, (_, i) => i); | ||
expect(log).toEqual(nums); |