From 75f5ab06377d97aa9ed5e4d4600bb61dc71f3eba Mon Sep 17 00:00:00 2001 From: tactonbishop Date: Sun, 4 Sep 2022 18:00:04 +0100 Subject: [PATCH] Last Sync: 2022-09-04 18:00:04 --- Programming_Languages/TypeScript/Function_overloads.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Programming_Languages/TypeScript/Function_overloads.md b/Programming_Languages/TypeScript/Function_overloads.md index b275ff5..d1f41b6 100644 --- a/Programming_Languages/TypeScript/Function_overloads.md +++ b/Programming_Languages/TypeScript/Function_overloads.md @@ -9,7 +9,7 @@ tags: Function overloading is not a feature of JavaScript but something close to it can be achieved with TypeScript. It proceeds by defining multiple function types (defined above the function) that may serve as the actual function's parameters. Then with the actual function, you leave the changeable parameters open as optional unions and/or `unknown` : -````ts +```ts // First oveload type: function logSearch(term: string, options?: string): void; @@ -30,9 +30,9 @@ function logSearch(term: string, p2?: unknown) { logSearch("apples", "braeburn"); logSearch("bananas", 3); -```` +``` -````ts +```ts // First overload type: function logSearchUnion(term: string, options?: string): void; @@ -53,4 +53,4 @@ function logSearchUnion(term: string, p2?: string | number) { logSearchUnion("melon", "honey-dew"); logSearchUnion("oranges", 4); -```` +```