-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/decorators): Fix capacity overflow with decorators (#8818)
- Loading branch information
Showing
4 changed files
with
175 additions
and
55 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
24 changes: 24 additions & 0 deletions
24
crates/swc_ecma_transforms_proposal/tests/decorators/issue-7358/2/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,24 @@ | ||
export function test() { | ||
// try putting this in stmts instead of at the top level | ||
@decorate() | ||
class Foo { | ||
|
||
@decorate() | ||
get name() { | ||
return "hello" | ||
} | ||
|
||
@decorate() | ||
sayHi() { | ||
return "hello" | ||
} | ||
} | ||
|
||
function decorate() { | ||
return function (target, { kind }) { | ||
console.log(target, kind) | ||
} | ||
} | ||
|
||
return new Foo(); | ||
} |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_transforms_proposal/tests/decorators/issue-7358/2/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 @@ | ||
{ | ||
"plugins": [["proposal-decorators", { "version": "2022-03" }]] | ||
} |
42 changes: 42 additions & 0 deletions
42
crates/swc_ecma_transforms_proposal/tests/decorators/issue-7358/2/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,42 @@ | ||
export function test() { | ||
var _dec, _initClass, _dec1, _dec2, _initProto; | ||
let _Foo; | ||
_dec = decorate(), _dec1 = decorate(), _dec2 = decorate(); | ||
// try putting this in stmts instead of at the top level | ||
class Foo { | ||
static{ | ||
({ e: [_initProto], c: [_Foo, _initClass] } = _apply_decs_2203_r(this, [ | ||
[ | ||
_dec1, | ||
3, | ||
"name" | ||
], | ||
[ | ||
_dec2, | ||
2, | ||
"sayHi" | ||
] | ||
], [ | ||
_dec | ||
])); | ||
} | ||
constructor(){ | ||
_initProto(this); | ||
} | ||
get name() { | ||
return "hello"; | ||
} | ||
sayHi() { | ||
return "hello"; | ||
} | ||
static{ | ||
_initClass(); | ||
} | ||
} | ||
function decorate() { | ||
return function(target, { kind }) { | ||
console.log(target, kind); | ||
}; | ||
} | ||
return new _Foo(); | ||
} |