I have defined a type called StateProps with the following properties
type StateProps = {
isPending: boolean,
asyncFn: (...args: any[]) => void | null
}
To initialize, I set up an initialState variable where the asyncFn property is initially set to null
let initialState = {
isPending: false,
asyncFn: null
}
Later on, I use this initialState in a React reducer like this:
const [state, dispatch] = useReducer(reducer, {...initialState})
However, this results in the error message:
Type 'null' is not assignable to type '(...args: any[]) => void | null'
I had assumed that my asyncFn could be either a function with any number of arguments or null if no function is provided, as indicated by the pipe symbol. Did I misunderstand something here?