Closed branchseer closed 2 weeks ago
For modifiers followed by computed properties [...] like private ['bar'] = 2, when the modifier(s) get stripped without semicolon, [...] may become the subscript part of the expression in the class element before.
[...]
private ['bar'] = 2
class A { foo = 1 private ['bar'] = 2 }
{ "jsc": { "parser": { "syntax": "typescript", "tsx": false }, "target": "es2022", "loose": true, "minify": { "compress": false, "mangle": false } }, "module": { "type": "commonjs" }, "minify": false, "isModule": true }
https://play.swc.rs/?version=1.7.40&code=H4sIAAAAAAAAA0vOSSwuVnBUqOZSAIK0%2FHwFWwVDMLugKLMssSRVIVo9KbFIPRYobsRVywUA1%2FC5JzAAAAA%3D&config=H4sIAAAAAAAAA1VPSQ7DIAy85xXI5x4qjv1DH4GoExGxCTtSUZS%2FFxKg7c2e8SzeJyFgJQ0PsZexLFElwjT2glD2rN4FAc4RSScTGW6dZarUrCzhCR0XA6zSglxVSPIuZVOADYGwwJw2bJAz3sz5N1IHFxMSdeeR5pRfLP4HTi0UXHhtJ9leqXVrgeLmgl8Jvpc9cbiDoWeX12rT8QEVPE3nGwEAAA%3D%3D&strip-types=
No response
Output:
class A { foo = 1 ;['bar'] = 2 }
class A { foo = 1['bar'] = 2 }
1.7.40
Describe the bug
For modifiers followed by computed properties
[...]
likeprivate ['bar'] = 2
, when the modifier(s) get stripped without semicolon,[...]
may become the subscript part of the expression in the class element before.Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.7.40&code=H4sIAAAAAAAAA0vOSSwuVnBUqOZSAIK0%2FHwFWwVDMLugKLMssSRVIVo9KbFIPRYobsRVywUA1%2FC5JzAAAAA%3D&config=H4sIAAAAAAAAA1VPSQ7DIAy85xXI5x4qjv1DH4GoExGxCTtSUZS%2FFxKg7c2e8SzeJyFgJQ0PsZexLFElwjT2glD2rN4FAc4RSScTGW6dZarUrCzhCR0XA6zSglxVSPIuZVOADYGwwJw2bJAz3sz5N1IHFxMSdeeR5pRfLP4HTi0UXHhtJ9leqXVrgeLmgl8Jvpc9cbiDoWeX12rT8QEVPE3nGwEAAA%3D%3D&strip-types=
SWC Info output
No response
Expected behavior
Output:
Actual behavior
Output:
Version
1.7.40
Additional context
No response