ts2322
2023-04-10typescript
A moment ago I got an error that reads like this:
Type '(() => void) | null' is not assignable to type '() => void | null'. ts2322
I was really confused for a moment. Then I realized (() => void) | null
means: Either a) a function that neither takes any argument nor returns any value; or b) null.
And () => void | null
means a function that does not take any argument. And there are two possibilities when this function returns: Either it doesn't return anything or it returns a null
.
Here's blog post explaining why the void
keyword is useful while devving.
And I mostly agree with this blog post.