0
我得到了以下錯誤而設置reuder
之一,打字稿無法設置初始狀態爲減速
/Users/Lxinyang/Desktop/angular/breakdown/ui/app/src/reducers/filters.spec.ts
(12,9): error TS2345: Argument of type '{}' is not assignable to parameter of type '{ selectionState: { source: string; timeRange: Date[]; }; } | undefined'.
Type '{}' is not assignable to type '{ selectionState: { source: string; timeRange: Date[]; }; }'.
Property 'selectionState' is missing in type '{}'.
的減速機的代碼,
const DATE_IN_MILLISECONDS = 60 * 60 * 24 * 1000
const todayDate = new Date()
const startDate = new Date(todayDate.getTime() - 6 * DATE_IN_MILLISECONDS)
const defaultFiltersState = {
selectionState: { source: 'all', timeRange: [startDate, todayDate] }
}
export function filters(state = defaultFiltersState, action: any) {}
我不知道爲什麼我我有這個問題,因爲我從未將{}
分配到默認狀態。下面
代碼爲根,
export default combineReducers({ dataSource, filters, filtersVideo })