Q40. What is function overload resolution?

Overloads present multiple call signatures to callers while one implementation handles all supported cases. The compiler selects a compatible overload based on the call arguments. Overloads should be precise and non-ambiguous; they do not create multiple runtime functions.

The implementation signature must be broad enough to handle all overload cases, but callers see the declared overload signatures.

Note

Interview approach: define the concept, explain why it matters, then mention one trade-off or limitation.

TypeScript concept
// Illustrative TypeScript contract
type Identifier = string;
const id: Identifier = "item-1";
💡 The example demonstrates the compile-time contract discussed in this question.
Key Takeaways
  • Explain the concept in your own words.
  • Know the practical trade-off and its limits.
  • Use a small example to demonstrate the idea.
Knowledge Check

How many runtime implementations are emitted for a normal overloaded function?