Skip to main content
InterviewHubPRO
Section Overview
Q24

Question 24 of 50

Part 2: Advanced Type System & Metaprogramming (Mid-Level)

48%
TypeScript Master (50 Qs)•Part 2: Advanced Type System & Metaprogramming (Mid-Level)

What are Overloaded Function Signatures?

junior LevelCode ExampletypescriptAdvanced Type System

In Simple Words: Function overloading allows a function to accept different combinations of parameters and return different types. You define multiple public function signatures followed by a single private implementation:

typescript
// Overload signatures (public API)
function format(value: string): string;
function format(value: number): string;
function format(value: boolean): number;

// Implementation signature (internal)
function format(value: string | number | boolean): string | number {
  if (typeof value === "boolean") return value ? 1 : 0;
  return value.toString();
}

const r1 = format("hello"); // Type: string
const r2 = format(true);    // Type: number