如何使用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>]>'.'.
答案 0 :(得分:1)
检查此
AndroidViewModel
答案 1 :(得分:0)
解决了:
new Map<string, IDoSomethingWith<Something>>([['somekey', new DoSomethingWith<Something>()]])