function overload
Several signatures declared for one function, each describing a different allowed combination of argument and return types.
In more detail
Overloads help when behaviour really differs by input, but writing one per type is tedious and misses new types. A generic signature is usually simpler when the output type just follows the input type.
Related terms
- generics — Types that take other types as parameters, so one definition works for many kinds of value.
- function signature — The name, parameters and their order that define how a function must be called.
Taught in
- Why Generics: Functions, Identities And Type Variables — Production TypeScript