我创建了一个对象reducerKeys
,其键和值等于另一个对象reducers
的键。我曾预计reducerKeys
的类型将像这样的{[key in keyof typeof reducerKeys]: key}
,但我发现它的类型是{[key in keyof typeof reducerKeys]: string}
。
这是我的代码:
const reducers = {
auth: authReducer,
travel: travelReducer,
}
export const reducerKeys = _.mapValues(reducers, (_, key) => key)
更新:
我预计reducerKeys
的类型为{auth: "auth", travel: "travel"}
,但我发现它为{auth: string, travel: string}