我的减速器有一种类型,例如:
export type Style = {
color: string;
(rest...)
}
export const initialState: Style = {
color: 'blue';
(rest...)
}
我有一个接受样式对象的组件,属性是可选的,只是覆盖样式的当前状态。类型如下所示:
export type InputStyle = {
color?: string;
(rest?...)
}
所以我基本上必须创建两种重复的类型,除了一种具有所有可选属性,一种没有。有没有更好的模式呢?我的直觉说这不是正确的方法。