I just needed to type an argument of one of my functions. Not a very uncommon task, but this time it could be two types, a string or a function. So I tried
function listen (event: string | () => void): void {}
This gives an error. Typescript doesn't understand anymore whats going on.
However, one way to fix this is to swap them
function listen (event: () => void | string): void {}
Well I guess it makes sense. Can someone explain to me whats going on here or point me to the right documentation

() => void | stringmeans() => (void | string). You want(() => void) | stringorstring | (() => void).