-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
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" .
yesmeck, hgezim, zpdDG4gta8XKpMCd, felixfbecker, lafe and 1 more
Metadata
Metadata
Assignees
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript