I have the following code:
enum A {
FOO = 0,
BAR = 1,
BAZ = 2
}
type B = {
[key in A]: number
}
declare let b: B;
It works fine. I can use b[A.FOO] but not b[123]. However, I'd like to also be able to use b.length, but when I add a property to type B, like so...
type B = {
length: number,
[key in A]: number
}
...I get the following errors
A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.ts(1170) A computed property name must be of type 'string', 'number', 'symbol', or 'any'.ts(2464)
How can I solve this?