Skip to content

Commit 1bb52f1

Browse files
function overloads
1 parent 80973af commit 1bb52f1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/app.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,20 @@ type Numeric = number | boolean;
2121

2222
type Universal = Combinable & Numeric;
2323

24+
function add(a: number, b: number): number;
25+
function add(a: string, b: string): string;
26+
function add(a: number, b: string): string;
27+
function add(a: string, b: number): string;
2428
function add(a: Combinable, b: Combinable) {
2529
if (typeof a === "string" || typeof b === "string") {
2630
return a.toString() + b.toString();
2731
}
2832
return a + b;
2933
}
3034

35+
const result = add("Dan", "the Man");
36+
result.split(" ");
37+
3138
type UnkownEmployee = Employee | Admin;
3239

3340
function printEmployeeInformation(emp: UnkownEmployee) {

0 commit comments

Comments
 (0)