Skip to content

[Feature]: Support @type() with ENUM argument (TypeScript) #201

Open
@endel

Description

@endel

Description & Use case

It's currently not possible to provide a TypeScript enum as argument for @type() decorator.

It should be possible to infer the most common enum scenarios, by using either string or number type under the hood.

Proposed API

Auto-detecting number types:

enum EquipmentSlot { ARMS, HEAD, BODY, LEGS };

class Equipment extends Schema {
  // same as @type("number")
  @type(EquipmentSlot) slot; 
}

Auto-detecting string types:

enum EquipmentSlot {
  ARMS = "ARMS",
  HEAD = "HEAD",
  BODY = "BODY",
  LEGS = "LEGS",
}

class Equipment extends Schema {
  // same as @type("string")
  @type(EquipmentSlot) slot; 
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions