Open
Description
Hey! I am trying to use the new decorators in this way:
.swcrc
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true
},
"transform": {
"decoratorVersion": "2022-03",
}
}
}
test.ts
function one(_target: unknown, context: ClassFieldDecoratorContext) {
context.addInitializer(function () {
const instance = this as { prop: number };
instance.prop = 1;
});
}
class Example {
@one
prop: number;
}
const instance = new Example();
console.log(instance.prop); // Output: undefined instead of 1
Using this command: SWCRC=true node --require @swc-node/register test.ts
The output is expected to be 1
(that is the output I get with ts-node
) but is undefined
with @swc-node/register
.
I have looked around and I am not sure if this is supposed to work yet.
Am I doing something wrong?
Metadata
Metadata
Assignees
Labels
No labels