使用TypeScript的新ts-check,我无法弄清楚如何处理泛型函数。
/**
* @type {Reducer<IPoiState, any>}
*/
const poi = handleActions({
[ADD_BOOKMARK_START]: (state) => {
return { ...state };
},
}, {});
handleActions类型来自Definitey Typed,看起来像......
export function handleActions<State>(
reducerMap: ReducerMap<State>,
initialState: State
): Reducer<State, any>;
所以,我收到的错误是......
Type 'Reducer<{}, any>' is not assignable to type 'Reducer<IPoiState, any>'.
Type '{}' is not assignable to type 'IPoiState'.
无论如何都要强制通用吗?