Currently, I have created a type and interface in TypeScript to explicitly define the things
variable and the Map
constructor call.
type Things = Map<string, ThingValue>;
interface ThingValue {
label: string;
count: number;
}
const things: Things = new Map<string, ThingValue>();
However, I would like to streamline this process and have a single type or interface to avoid repeating <string, ThingValue>
.
Is there a way to achieve this in TypeScript?
Alternatively, what are the recommended practices for typing JavaScript Map
s?