In Typescript there is a way to get the size of the array or tuple and use it as a type:
type Tuple = [number, string, boolean];
type Arr = [0, 1, 2];
type LengthOf<T extends any[]> = T["length"];
type Test = LengthOf<Tuple>; // 3
type Test2 = LengthOf<Arr>; // 3
Is there any way to do the same thing (extract the length/size) with enums? Enum example:
enum Example {
how = "how",
to = "to",
count = "count",
enum = "enum",
entries = "entries"
}
And just to be clear, I'm interested in getting this as a type NOT a value. I know about Object.keys(Example).length.