Overload Functions to Enrich your Definition

In this lesson, we will discuss enriching functions with several signatures of overload.

The reason to use overloaded functions

TypeScript allows us to have an overloaded function. Often, the term ‘overload’ is linked to an object-oriented concept which you will see later. Any function, even if not in a class, can have an overload. The reason to use overload functions is that you may have a function that takes some required parameters only in a specific scenario. Instead of using the overloaded functions, it’s possible to use optional parameters and default parameters.

The advantage of overloaded functions is clarity for the consumer. A consumer sees several functions with different signatures (parameters and return types). However, it’s still a single function.

Get hands-on with 1200+ tech skills courses.