function reverse(x: number): number;
function reverse(x: string): string;
function reverse(x: number | string): number | string {
return x + '1';
}
Why typescript OK with this function overloading? I want to limit the number input number output and string input string output.
In my function implementation, I deliberately let the number input string output. And I expect that an error message would be thrown when compiling this ts file, but it didn't. Why?
ENVIRONMENT: Without tsconfig.json and tsc version is 4.4.3