Closed
Description
It is impossible to write generic type that represents key-value dictionary:
interface KeyValue<Key, Value> {
[key: Key]: Value;
}
Key must be string or number, but generic constraints doesn't allow this.
interface KeyValue<Key extends string|number, Value> {
[key: Key]: Value; // Still error
}
There is 'extends' but there is no 'is' to match exact type.
Something like "Key is string|number" or "Key: string|number" .