Describe the bug
Currently, swc transforms decorators even when the output target is explicitly set to esnext. This behavior deviates from tsc (verified up to version 6.0.2), which leaves decorators intact under the esnext target.
Input code
function decorator() {}
@decorator
class someclass {
@decorator
somemethod(){}
}
Config
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03"
},
"target": "esnext"
}
}
Link to the code that reproduces this issue
https://play.swc.rs/?version=1.15.24&code=H4sIAAAAAAAAA0srzUsuyczPU0hJTc4vSizJL9LQVKiu5eJygAtwJeckFhcrFOfnpkJY1VxcCkCApALEBcnnppZk5KdoaAINqOUCAMy8AmRbAAAA&config=H4sIAAAAAAAAA1WNwQqDQAxE737FknMFWW%2F9kN7DNi0K7sokBYvsvzdaLPaWmZeZWZsQaNRE17D66WJmqOCn3dF3Nl7cIUkTa8IwG10OepdUwFag%2FmF4yQ7ql5OBsz4KplPhOXQT6FDyVh67GNuup%2F884ym2b2uWxTZam%2FoBjEo2B7cAAAA%3D
SWC Info output
Operating System:
Platform: win32
Arch: x64
Machine Type: x86_64
Version: Windows 11 Pro
CPU: (16 cores)
Models: AMD Ryzen 7 7840U w/ Radeon 780M Graphics
Binaries:
Node: 25.6.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
@swc/core: 1.15.24
@swc/helpers: N/A
@swc/types: 0.1.26
typescript: 6.0.2
SWC Config:
output: N/A
.swcrc path: N/A
Next.js info:
output: N/A
Expected behavior
When target is set to "esnext", decorators should not be transformed, mirroring the behavior of tsc.
Actual behavior
Decorators are being transformed, regardless of the esnext target.
Version
1.15.24
Additional context
No response
Describe the bug
Currently,
swctransforms decorators even when the output target is explicitly set toesnext. This behavior deviates fromtsc(verified up to version 6.0.2), which leaves decorators intact under theesnexttarget.Input code
Config
{ "jsc": { "parser": { "syntax": "ecmascript", "decorators": true }, "transform": { "decoratorVersion": "2022-03" }, "target": "esnext" } }Link to the code that reproduces this issue
https://play.swc.rs/?version=1.15.24&code=H4sIAAAAAAAAA0srzUsuyczPU0hJTc4vSizJL9LQVKiu5eJygAtwJeckFhcrFOfnpkJY1VxcCkCApALEBcnnppZk5KdoaAINqOUCAMy8AmRbAAAA&config=H4sIAAAAAAAAA1WNwQqDQAxE737FknMFWW%2F9kN7DNi0K7sokBYvsvzdaLPaWmZeZWZsQaNRE17D66WJmqOCn3dF3Nl7cIUkTa8IwG10OepdUwFag%2FmF4yQ7ql5OBsz4KplPhOXQT6FDyVh67GNuup%2F884ym2b2uWxTZam%2FoBjEo2B7cAAAA%3D
SWC Info output
Expected behavior
When
targetis set to "esnext", decorators should not be transformed, mirroring the behavior oftsc.Actual behavior
Decorators are being transformed, regardless of the
esnexttarget.Version
1.15.24
Additional context
No response