function parse(input: string): number;
function parse(input: number): string;
function parse(input: string | number) {
return typeof input === "string" ? Number(input) : String(input);
}
declare const v: string | number;
parse(v)The answer is parse(v). Callers see only the two overload signatures. One takes string and one takes number, and neither accepts string | number.
"None of them" is tempting, because the implementation accepts string | number. But the implementation signature is not visible from outside. Adding a third overload for the union fixes it.
Read more