Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: ensure initializer is invoked without parameters * fix: assert class decorators return a callable or undefined * fix: accessor decorator returns { initialize?: (initialValue: unknown) => unknown }; * fix: assert accessor decorator returns callable get/set/initialize * add getter/setter test cases * add accessor-initializers ordering test * address review comments * remove unused param base * add leaked context addInitializer test
- Loading branch information
Showing
33 changed files
with
243 additions
and
61 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
4 changes: 2 additions & 2 deletions
4
...babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/private/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
4 changes: 2 additions & 2 deletions
4
.../babel-plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/public/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
4 changes: 2 additions & 2 deletions
4
...lugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/static-private/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
4 changes: 2 additions & 2 deletions
4
...plugin-proposal-decorators/test/fixtures/2021-12-getters--to-es2015/static-public/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
4 changes: 2 additions & 2 deletions
4
...-proposal-decorators/test/fixtures/2021-12-getters-and-setters--to-es2015/private/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
4 changes: 2 additions & 2 deletions
4
...n-proposal-decorators/test/fixtures/2021-12-getters-and-setters--to-es2015/public/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
4 changes: 2 additions & 2 deletions
4
...al-decorators/test/fixtures/2021-12-getters-and-setters--to-es2015/static-private/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
4 changes: 2 additions & 2 deletions
4
...sal-decorators/test/fixtures/2021-12-getters-and-setters--to-es2015/static-public/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
4 changes: 2 additions & 2 deletions
4
...sal-decorators/test/fixtures/2021-12-methods--to-es2015/private-with-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
4 changes: 2 additions & 2 deletions
4
...osal-decorators/test/fixtures/2021-12-methods--to-es2015/public-with-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
4 changes: 2 additions & 2 deletions
4
...orators/test/fixtures/2021-12-methods--to-es2015/static-private-with-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
4 changes: 2 additions & 2 deletions
4
...corators/test/fixtures/2021-12-methods--to-es2015/static-public-with-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
21 changes: 21 additions & 0 deletions
21
...orators/test/fixtures/2021-12-misc--to-es2015/leaked-proto-context-addInitializer/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,21 @@ | ||
let addInitializer, i = 0; | ||
const logs = []; | ||
|
||
function decCallProtoAddInitializer() { | ||
addInitializer(() => logs.push(i++)); | ||
} | ||
|
||
function decMethod(_, context) { | ||
({ addInitializer } = context); | ||
addInitializer(() => logs.push(i++)); | ||
} | ||
|
||
@decCallProtoAddInitializer | ||
class C { | ||
@decMethod m() {} | ||
@decCallProtoAddInitializer static n() {} | ||
} | ||
|
||
new C; | ||
|
||
expect(logs).toEqual([0, 1]); |
21 changes: 21 additions & 0 deletions
21
...rators/test/fixtures/2021-12-misc--to-es2015/leaked-static-context-addInitializer/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,21 @@ | ||
let addInitializer, i = 0; | ||
const logs = []; | ||
|
||
function decCallStaticAddInitializer() { | ||
addInitializer(() => logs.push(i++)); | ||
} | ||
|
||
function decStaticMethod(_, context) { | ||
({ addInitializer } = context); | ||
addInitializer(() => logs.push(i++)); | ||
} | ||
|
||
@decCallStaticAddInitializer | ||
class C { | ||
@decStaticMethod static m() {} | ||
@decCallStaticAddInitializer n() {} | ||
} | ||
|
||
new C; | ||
|
||
expect(logs).toEqual([0, 1]); |
46 changes: 46 additions & 0 deletions
46
...oposal-decorators/test/fixtures/2021-12-ordering--to-es2015/accessor-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,46 @@ | ||
var log = []; | ||
|
||
function push(x) { log.push(x); return x; } | ||
|
||
function logClassDecoratorRun(a, b, c) { | ||
push(a); | ||
return function (el, { addInitializer }) { | ||
push(b); | ||
addInitializer(function () { push(c); }); | ||
return el; | ||
}; | ||
} | ||
|
||
function logAccessorDecoratorRun(a, b, c, d) { | ||
push(a); | ||
return function (el, { addInitializer }) { | ||
push(b); | ||
addInitializer(function () { push(c); }); | ||
return { | ||
initialize: () => push(d) | ||
}; | ||
}; | ||
} | ||
|
||
@logClassDecoratorRun(0, 19, 29) | ||
@logClassDecoratorRun(1, 18, 28) | ||
class A { | ||
@logAccessorDecoratorRun(2, 11) | ||
@logAccessorDecoratorRun(3, 10) | ||
accessor a; | ||
|
||
@logAccessorDecoratorRun(4, 13, 21, 25) | ||
@logAccessorDecoratorRun(5, 12, 20, 24) | ||
static accessor b; | ||
|
||
@logAccessorDecoratorRun(6, 15, 23, 27) | ||
@logAccessorDecoratorRun(7, 14, 22, 26) | ||
static accessor #c; | ||
|
||
@logAccessorDecoratorRun(8, 17) | ||
@logAccessorDecoratorRun(9, 16) | ||
accessor #d; | ||
} | ||
|
||
var nums = Array.from({ length: 30 }, (_, i) => i); | ||
expect(log).toEqual(nums); |
Oops, something went wrong.