export type EnumShape<T> = [T, ...T[]]
class Container<Enum extends EnumShape<string>> {
referencedEnum: Enum
defaultValue: string
constructor(referencedEnum: Enum) {
this.referencedEnum = referencedEnum
}
public default(key: /** what type we need here */) {
this.defaultValue = key
}
}
let container = new Container(["A", "B"])
container.default("A") // this has to compile
container.default("C") // this is a type error
export type EnumShape<T> = [T, ...T[]]
class Container<Enum extends EnumShape<string>> {
referencedEnum: Enum
defaultValue: string
constructor(referencedEnum: Enum) {
this.referencedEnum = referencedEnum
}
public default(key: /** what type we need here */) {
this.defaultValue = key
}
}
let container = new Container(["A", "B"])
container.default("A") // this has to compile
container.default("C") // this is a type error