Open
Description
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;
}