[typescript] Initialize a Map containing arrays

I want to make a Map where each member contains an array of strings. But how do I initialize and type it (in a single statement)?

I've tried this:

  private _gridOptions:Map<string, Array<string>> = {"1": ["test"]};

and I get:

Module build failed: Error: /Users/*****/Work/dashboard/src/app/core/pg.service.ts (8,5): Type '{ "1": string[]; }' is not assignable to type 'Map<string, string[]>'.

This question is related to typescript

The answer is


Per Mozilla's Map documentation, you can initialize as follows:

private _gridOptions:Map<string, Array<string>> = 
    new Map([
        ["1", ["test"]],
        ["2", ["test2"]]
    ]);