-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Describe the bug
The following code works in TypeScript, but not in swc.
Input code
enum CHAR {
["\t"] = 0x09,
["\n"] = 0x0A,
["\v"] = 0x0B,
["\f"] = 0x0C,
["\r"] = 0x0D,
[" "] = 0x20,
["-"] = 0x2D,
["["] = 0x5B
}
const c = "\n"
console.log(c.charCodeAt(0) === CHAR["\n"]);Config
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false
},
"target": "es5",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}Link to the code that reproduces this issue
SWC Info output
No response
Expected behavior
Should not error.
Actual behavior
x Computed property names are not allowed in enums
,-[input.ts:2:1]
1 | enum CHAR {
2 | ["\t"] = 0x09,
: ^^^^^
3 | ["\n"] = 0x0A,
4 | ["\v"] = 0x0B,
4 | ["\f"] = 0x0C,
`----
Version
1.13.20
Additional context
No response