How to set "paramtypes" metadata in Javascript?

I'm currently working on NodeJs/Javascript setup (no typescript) that relies on decorators. Unfortunately I'm not able to convince swc to emit correct metadata. Here's an example

function decorator() {}

class Foo {
  /**
   * @param {string} x
   */
  @decorator
  foo(x) {
    return 'foo';
  }
} 


Compiling it with the following
.swcrc


{
  "$schema": "https://swc.rs/schema.json",
  "module": {
    "type": "commonjs"
  },
  "jsc": {
    "target": "es2022",
    "parser": {
      "syntax": "ecmascript",
      "decorators": true
    },
    "transform": {
      "legacyDecorator": true,
      "decoratorMetadata": true
    },
    "externalHelpers": true,
    "loose": true,
    "keepClassNames": true,
  },
  "sourceMaps": false
}


gives me

"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
const _ts_decorate = require("@swc/helpers/_/_ts_decorate");
const _ts_metadata = require("@swc/helpers/_/_ts_metadata");
function decorator() {}
let Foo = class Foo {
    foo(x) {
        return 'foo';
    }
};
_ts_decorate._([
    decorator,
    _ts_metadata._("design:type", Function),
    _ts_metadata._("design:paramtypes", [
        void 0 // <<---- How would I get `String` here?
    ]),
    _ts_metadata._("design:returntype", void 0)
], Foo.prototype, "foo", null);


Does anybody know how to get
swc
to emit correct
design:paramtypes
metadata in a JS setup?
Solution
You can’t
Was this page helpful?