paint-brush
Understanding Function Overloading in TypeScriptby@olgakiba
11,649 reads
11,649 reads

Understanding Function Overloading in TypeScript

by Olga Kiba9mOctober 10th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

In TypeScript, we can specify a function that can be called in different ways by writing function overloading signatures. To get **overload signatures**, we should write two function signatures: one accepting a string type, and another accepting argument with an array of numbers type. Overload 1 of 2, '(s: string): number', gave the following error error: 'Hello' is not assignable to type 'number' Type 'number[]' is 'not assignable' to type'string.
featured image - Understanding Function Overloading in TypeScript
Olga Kiba HackerNoon profile picture
Olga Kiba

Olga Kiba

@olgakiba

Love Chinese culture and coding

0-item

STORY’S CREDIBILITY

Code License

Code License

The code in this story is for educational purposes. The readers are solely responsible for whatever they build with it.

L O A D I N G
. . . comments & more!

About Author

Olga Kiba HackerNoon profile picture
Olga Kiba@olgakiba
Love Chinese culture and coding

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite