创建Map <string,idosomethingwith <something =“”>的实例

时间:2019-01-14 20:01:35

标签: typescript

如何使用TypeScript在此通用Map实例中创建?

Map<string, IDoSomethingWith<Something>>

我尝试过:

const test: ReadonlyArray<string> = ['somekey'];
new Map<string, IDoSomethingWith<Something>>(test)

但是我不知道如何传递IDoSomethingWith<Something>的实例。

我收到此错误:

Type 'string' is not assignable to type 'ReadonlyArray<[string, IDoSomethingWith<Something>]>'.'.

2 个答案:

答案 0 :(得分:1)

检查此

AndroidViewModel

答案 1 :(得分:0)

解决了:

new Map<string, IDoSomethingWith<Something>>([['somekey', new DoSomethingWith<Something>()]])