Untitled diff

Created Diff never expires
11 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
34 lines
10 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
33 lines
import ow from "ow";
import ow from "ow";


function myMethod(a: string): string;
function myMethod(a: string): string;
function myMethod(a: number): number;
function myMethod(a: number): number;
function myMethod(a: number, b: string): string;
function myMethod(a: number, b: string): [string, string];
function myMethod(a: any, b?: string): any {
function myMethod(a: string | number, b?: string) {
if (ow.isValid(a, ow.string) && ow.isValid(b, ow.undefined)) {
if (ow.isValid(a, ow.string) && ow.isValid(b, ow.undefined)) {
console.log("function myMethod(a: string): string");
console.log("function myMethod(a: string): string");
return a;
return a;
}
}


if (ow.isValid(a, ow.number) && ow.isValid(b, ow.undefined)) {
if (ow.isValid(a, ow.number) && ow.isValid(b, ow.undefined)) {
console.log("function myMethod(a: number): number");
console.log("function myMethod(a: number): number");
return a;
return a;
}
}


if (ow.isValid(a, ow.number) && ow.isValid(b, ow.string)) {
if (ow.isValid(a, ow.number) && ow.isValid(b, ow.string)) {
console.log("function myMethod(a: string, b: string): string");
console.log("function myMethod(a: number, b: string): [string, string]");
return [a, b];
return [a, b];
}
}
}
}


Text moved to lines 27-30
console.log(myMethod(123));
// function myMethod(a: number): number
// 123

console.log(myMethod("Andrew"));
console.log(myMethod("Andrew"));
// function myMethod(a: string): string
// function myMethod(a: string): string
// Andrew
// Andrew


Text moved from lines 23-26
console.log(myMethod(123));
// function myMethod(a: number): number
// 123

console.log(myMethod(123, "Andrew"));
console.log(myMethod(123, "Andrew"));
// function myMethod(a: string, b: string): string
// function myMethod(a: number, b: string): [string, string]
// [123, "Andrew"]
// [123, "Andrew"]