I'm struggling to understand the type error generated by the following code. Can anyone point out what I might be doing incorrectly?
Type '(state: State) => State' is not assignable to type 'Action'.
Types of parameters 'state' and 'state' are incompatible.
Type 'S' is not assignable to type 'State'.
The error occurs specifically on line 14 (const action: Action = ...
).
interface IState {
count: number;
}
class State implements IState {
count: number;
}
type Action = <S>(state: S) => S
type Dispatch = <A extends Action>(action: A) => void
const dispatch = (action: Action) => { }
const action: Action = (state: State) => state
dispatch(action)
I would expect State
and the generic type S
to be compatible.