Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a key, value pair object within an interface in Angular?

It seems quite a simple problem. I am basically trying to create a key value pair object within an interface I have created.

However I have no idea of how to implement this. I consistently get the error Generic type 'Map' requires 2 type argument(s)

My interface object looks like this. I am trying to make the 'type' object to a key, value pair.

export interface CalendarEvent<MetaType = any> {
    id?: string | number;
    start: Date;
    end?: Date;
    title: string;
    color?: EventColor;
    actions?: EventAction[];
    allDay?: boolean;
    cssClass?: string;
    resizable?: {
        beforeStart?: boolean;
        afterEnd?: boolean;
    };
    draggable?: boolean;
    meta?: MetaType;
    amount: number;
    type: Map<key: string, value: string>
}
like image 385
Edward Muldrew Avatar asked Aug 17 '26 20:08

Edward Muldrew


1 Answers

Just supply the generic type - remove the parameter names, i.e:

Map<string, string>

like image 173
Johan Swanepoel Avatar answered Aug 20 '26 14:08

Johan Swanepoel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!