Imagine we have a generic interface:
export interface IKeyValue<K, V> {
key: K;
value: V;
}
Now, our goal is to define a variable or field and restrict the types that can be used as K
and V
:
public items: IKeyValue<K extends Type1, V extends Type2>[];
This code does not compile.
I am working with TypeScript 2.6.
How can we accomplish this in TypeScript?