4 ms·
That's still awkward and confusing for what would be one of the most common use-cases, if it were less awkward.
by mjhay 4y ago
That's still awkward and confusing for what would be one of the most common use-cases, if it were less awkward.
- throwanem 4y agoHow would you simplify the syntax here?
- itslennysfault 4y agoI'd like to be able to just do... type UserType = 'default' | 'admin' | 'manager'; interface UserTypeCounts { [key: UserType]: number } Not the best example, but it gets the point across. When you do this it says the key must be a string type which it actually is. It's just a string limited to specific values. Yes, I could do an interface with explicitly named keys instead, but if that type (or enum) could have dozens of possible values it's annoying to duplicate it.