Is there a way to define a type for a function that includes additional properties like this?
foo({ name: 'john' })
foo.type
I tried the following solution, but TypeScript seems to think that foo only returns the function and cannot be called with the payload argument.
type FunctionWithType = {
(): (payload: { name: string}) => ({ type: string; payload: { name: string }});
type: string
}
You can view the playground with the example above and my attempt at a solution here (edited)