-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle decorated async private method and generator (#16258)
- Loading branch information
Showing
9 changed files
with
134 additions
and
17 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
23 changes: 23 additions & 0 deletions
23
...l-decorators/test/fixtures/2023-11-methods--to-es2015/private-async-and-generator/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 @@ | ||
let counter = 0; | ||
|
||
class Foo { | ||
@(function (fn) { | ||
counter++; | ||
expect(fn.constructor.name).toBe("AsyncFunction"); | ||
}) | ||
async #a() {} | ||
|
||
@(function (fn) { | ||
counter++; | ||
expect(fn.constructor.name).toBe("GeneratorFunction"); | ||
}) | ||
*#g() {} | ||
|
||
@(function (fn) { | ||
counter++; | ||
expect(fn.constructor.name).toBe("AsyncGeneratorFunction"); | ||
}) | ||
async *#ag() {} | ||
} | ||
|
||
expect(counter).toBe(3); |
10 changes: 10 additions & 0 deletions
10
...-decorators/test/fixtures/2023-11-methods--to-es2015/private-async-and-generator/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,10 @@ | ||
class Foo { | ||
@dec | ||
async #a() {} | ||
|
||
@dec | ||
*#g() {} | ||
|
||
@dec | ||
async *#ag() {} | ||
} |
3 changes: 3 additions & 0 deletions
3
...orators/test/fixtures/2023-11-methods--to-es2015/private-async-and-generator/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 @@ | ||
{ | ||
"minNodeVersion": "10.0.0" | ||
} |
26 changes: 26 additions & 0 deletions
26
...decorators/test/fixtures/2023-11-methods--to-es2015/private-async-and-generator/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,26 @@ | ||
var _initProto, _dec, _call_a, _dec2, _call_g, _dec3, _call_ag, _Foo; | ||
_dec = dec; | ||
_dec2 = dec; | ||
_dec3 = dec; | ||
var _ag = /*#__PURE__*/new WeakMap(); | ||
var _g = /*#__PURE__*/new WeakMap(); | ||
var _a = /*#__PURE__*/new WeakMap(); | ||
class Foo { | ||
constructor() { | ||
babelHelpers.classPrivateFieldInitSpec(this, _ag, { | ||
writable: true, | ||
value: _call_ag | ||
}); | ||
babelHelpers.classPrivateFieldInitSpec(this, _g, { | ||
writable: true, | ||
value: _call_g | ||
}); | ||
babelHelpers.classPrivateFieldInitSpec(this, _a, { | ||
writable: true, | ||
value: _call_a | ||
}); | ||
_initProto(this); | ||
} | ||
} | ||
_Foo = Foo; | ||
[_call_a, _call_g, _call_ag, _initProto] = babelHelpers.applyDecs2311(_Foo, [[_dec, 2, "a", async function () {}], [_dec2, 2, "g", function* () {}], [_dec3, 2, "ag", async function* () {}]], [], 0, _ => _a.has(babelHelpers.checkInRHS(_))).e; |
23 changes: 23 additions & 0 deletions
23
...gin-proposal-decorators/test/fixtures/2023-11-methods/private-async-and-generator/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 @@ | ||
let counter = 0; | ||
|
||
class Foo { | ||
@(function (fn) { | ||
counter++; | ||
expect(fn.constructor.name).toBe("AsyncFunction"); | ||
}) | ||
async #a() {} | ||
|
||
@(function (fn) { | ||
counter++; | ||
expect(fn.constructor.name).toBe("GeneratorFunction"); | ||
}) | ||
*#g() {} | ||
|
||
@(function (fn) { | ||
counter++; | ||
expect(fn.constructor.name).toBe("AsyncGeneratorFunction"); | ||
}) | ||
async *#ag() {} | ||
} | ||
|
||
expect(counter).toBe(3); |
10 changes: 10 additions & 0 deletions
10
...in-proposal-decorators/test/fixtures/2023-11-methods/private-async-and-generator/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,10 @@ | ||
class Foo { | ||
@dec | ||
async #a() {} | ||
|
||
@dec | ||
*#g() {} | ||
|
||
@dec | ||
async *#ag() {} | ||
} |
3 changes: 3 additions & 0 deletions
3
...roposal-decorators/test/fixtures/2023-11-methods/private-async-and-generator/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 @@ | ||
{ | ||
"minNodeVersion": "16.11.0" | ||
} |
15 changes: 15 additions & 0 deletions
15
...n-proposal-decorators/test/fixtures/2023-11-methods/private-async-and-generator/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,15 @@ | ||
var _initProto, _dec, _call_a, _dec2, _call_g, _dec3, _call_ag; | ||
_dec = dec; | ||
_dec2 = dec; | ||
_dec3 = dec; | ||
class Foo { | ||
static { | ||
[_call_a, _call_g, _call_ag, _initProto] = babelHelpers.applyDecs2311(this, [[_dec, 2, "a", async function () {}], [_dec2, 2, "g", function* () {}], [_dec3, 2, "ag", async function* () {}]], [], 0, _ => #a in _).e; | ||
} | ||
constructor() { | ||
_initProto(this); | ||
} | ||
#ag = _call_ag; | ||
#g = _call_g; | ||
#a = _call_a; | ||
} |