What is a function overload in TypeScript?

Why Interviewers Ask This

This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex TypeScript topics. It also reveals how well you can explain technical ideas to non-experts.

Answer

Function overloads allow you to define multiple call signatures for a single function, letting it accept different argument types and return different types based on what is passed. You declare the overload signatures first (without body), then implement with a single implementation signature (with body): function format(value: string): string; function format(value: number): string; function format(value: string | number): string { return String(value); }. TypeScript uses the overload signatures for type checking (not the implementation signature) — callers see only the declared overloads. Overloads are resolved in order — TypeScript picks the first matching signature. The implementation signature must be compatible with all overload signatures. Use overloads when a function's return type or behavior genuinely depends on the argument types. For simpler cases, union types and optional parameters are cleaner. Overloads also work on class methods and interface methods.

Pro Tip

Back up your answer with a specific project or situation. Saying 'In my last TypeScript project, I used this when...' immediately makes your answer more credible and memorable.