Understanding Function Overloading in TypeScriptby@olgakiba
769 reads

Understanding Function Overloading in TypeScript

tldt arrow
Read on Terminal Reader🖨️

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

@olgakiba

Olga Kiba

Credibility

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa