Interface for dynamic key in typescript

后端 未结 6 1624
一生所求
一生所求 2020-12-05 12:33

I have an Object like this that is created by underscore\'s _.groupBy() method.

myObject = {
  \"key\" : [{Object},{Object2},{Object3}],
  \"key         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 13:05

    I would suggest a solution with Map, maybe for someone it will be useful:

    type TKey = 'key1' | 'key2' | 'key3';
    type TValue = object[];
    
    type TMapper = Map; // But also you can use Record instead of Map
    

提交回复
热议问题