I have a type set up as follows
type StateProps = {
isPending: boolean,
asyncFn: (...args: any[]) => void | null
}
I then create an initialState variable which has null for asyncFn
let initialState = {
isPending: false,
asyncFn: null
}
Then later in I use it in a react reducer as follows.
const [state, dispatch] = useReducer(reducer, {...initialState})
but it produces the following error
Type 'null' is not assignable to type '(...args: any[]) => void | null'
I thought that my asyncFn could be a function (with any number of args) or null if no function is supplied, as indicated by the single pipe symbol. Have I misunderstood this?