Reputation: 8189
Using TypeScript's new ts-check, I can't figure out how to handle working with a generic function.
/**
* @type {Reducer<IPoiState, any>}
*/
const poi = handleActions({
[ADD_BOOKMARK_START]: (state) => {
return { ...state };
},
}, {});
The handleActions type comes from Definitey Typed and looks like...
export function handleActions<State>(
reducerMap: ReducerMap<State>,
initialState: State
): Reducer<State, any>;
So, I'm getting an error saying that...
Type 'Reducer<{}, any>' is not assignable to type 'Reducer<IPoiState, any>'.
Type '{}' is not assignable to type 'IPoiState'.
Is there anyway to force the generic through?
Upvotes: 0
Views: 271
Reputation: 1439
You can cast or type assert the object by adding the Type you want it to be in front with angle braces like this <IPoiState>{}
.
Upvotes: 1