Skip to content

design:type wrong for enum values #1160

@hcesar

Description

@hcesar

Describe the bug
In TSC, when you have an enum type, the base enum type is set as design:type.
SWC is setting the enum object itself.

Input code

enum MyEnum {
  x = "xxx",
  y = "yyy"
}

class Xpto {
  @Decorator()
  value!: MyEnum;
}

function Decorator() {
  return function (...args) {};
}

Config

{
  "module": {
    "type": "commonjs"
  },
  "jsc": {
    "target": "es2018",
    "parser": {
      "syntax": "typescript",
      "decorators": true,
      "dynamicImport": false
    },
    "transform": {
      "legacyDecorator": false,
      "decoratorMetadata": true
    }
  }
}

Expected behavior
A clear and concise description of what you expected to happen.

TSC:

__decorate([
    Decorator(),
    __metadata("design:type", String)
], Xpto.prototype, "value", void 0);

SWC:

Reflect.metadata("design:type", typeof MyEnum === "undefined" ? Object : MyEnum)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions