如何为该数据结构创建Redux类型?



如何为这种类型的数据结构创建接口或类型以存储到redux中?

{
"22": [{
"pageId": "interiorother",
"rowControls": []
}, {
"pageId": "someotherkey",
"rowControls": []
}],
"23": [{
"pageId": "interiorother",
"rowControls": []
}, {
"pageId": "someotherkey",
"rowControls": []
}]
}

我试过了:const initialState:

{[key: string]: []} = { '': [] };

但是我的eslint告诉我在索引签名上使用Record。当我忽略它时,我在设置对象时遇到了麻烦,像这样:

setAuditId: (state, action: PayloadAction<string>) => {
state = { ...state[action.payload] = [] };
return state;
},

应该是这样的;

interface dttype {
[key: string]: Array<{ pageId: string; rowControls: Array<string> }>;
}

我假设rowControls是一个字符串数组。

最新更新