-
-
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): Support negative numbers (#10114)
**Description:** A negative number is not a numeric literal so we need to handle unary expressions with `op = "-"`. **Related issue:** - Closes #10094
- Loading branch information
Showing
5 changed files
with
77 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
swc_core: patch | ||
swc_ecma_transforms_proposal: patch | ||
--- | ||
|
||
fix(es/decorators): Support negative numbers |
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 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"decorators": true, | ||
"tsx": false | ||
}, | ||
"target": "es2022", | ||
"loose": false, | ||
"minify": { | ||
"compress": false, | ||
"mangle": false | ||
}, | ||
"transform": { | ||
"decoratorMetadata": true | ||
} | ||
}, | ||
"module": { | ||
"type": "es6" | ||
}, | ||
"minify": false, | ||
"isModule": true | ||
} |
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,19 @@ | ||
enum NegativeStatus { | ||
open = -1, | ||
close = 3, | ||
} | ||
|
||
enum Status { | ||
open = 1, | ||
close = 2, | ||
} | ||
|
||
function prop() { } | ||
|
||
class A { | ||
@prop() | ||
negativeStatus: NegativeStatus; | ||
|
||
@prop() | ||
status: Status; | ||
} |
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,25 @@ | ||
var _ts_decorate = require("@swc/helpers/_/_ts_decorate"); | ||
var _ts_metadata = require("@swc/helpers/_/_ts_metadata"); | ||
var NegativeStatus = /*#__PURE__*/ function(NegativeStatus) { | ||
NegativeStatus[NegativeStatus["open"] = -1] = "open"; | ||
NegativeStatus[NegativeStatus["close"] = 3] = "close"; | ||
return NegativeStatus; | ||
}(NegativeStatus || {}); | ||
var Status = /*#__PURE__*/ function(Status) { | ||
Status[Status["open"] = 1] = "open"; | ||
Status[Status["close"] = 2] = "close"; | ||
return Status; | ||
}(Status || {}); | ||
function prop() {} | ||
class A { | ||
negativeStatus; | ||
status; | ||
} | ||
_ts_decorate._([ | ||
prop(), | ||
_ts_metadata._("design:type", Number) | ||
], A.prototype, "negativeStatus", void 0); | ||
_ts_decorate._([ | ||
prop(), | ||
_ts_metadata._("design:type", Number) | ||
], A.prototype, "status", void 0); |
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