我在创建一个 Map,其中每个条目都保存字符串数组。怎样在一条语句中同时声明类型并完成初始化?
我(天真地)这样试了一下。
private _rowEntries:Map<string, Array<string>> = {"3": ["sampleA"]};
结果是下面这个错误。
Module build failed: Error: /Users/arden/Work/controlpanel/src/app/core/rows.service.ts (12,7): Type '{ "3": string[]; }' is not assignable to type 'Map<string, string[]>'.