Anyone know how to define a type for a function that has additional properties e.g.
foo({ name: 'john' })
foo.type
I assumed the following would work but TS believes that foo instead returns the function and is not callable itself with the payload argument.
type FuncWithType = {
(): (payload: { name: string}) => ({ type: string; payload: { name: string }});
type: string
}
Playground with above example and my faulty solution https://www.typescriptlang.org/play?#code/C4TwDgpgBAYgrgOwMYHUCWwAWAVc0C8UA3gFBRQAUAlAFyVgC[…]QgSJFYEUSgGOnhkdCxcSAUoAAZ3BgpScj5BOgByYAhRItcqbIA6RyA (edited)