我有一个流类型UserState
,我将其定义为reducer的返回类型。我在返回类型中添加了一个额外的hey
道具,但没有收到错误。我本来期待Property not found in object type
无论如何,如果有人知道我做错了什么,我很乐意听到。感谢。
type UserState = {
+female?: boolean,
}
const user = (state: UserState = {}, action: ReduxFetchUserAction): UserState => {
switch (action.type) {
case types.FETCH_USER_SUCCESS: {
const newUser = { ...state, ...action.user, hey: 'whatgives' }
return newUser
}
default:
return state
}
}
export default user