So we can do:
export function myMethod (param: number) :number export function myMethod (param: string) :string export function myMethod (param: string | nu
This solution is based on @Sam96 but keeps the code of the arrow function fully typed.
type Create = { (): Vector<0>; (x: T): Vector; (x: T, y: T): Vector; }; const create: Create = ( x?: T, y?: T ) => ({ x: x ?? 0, y: y ?? x ?? 0, });