Find: Wrong Function Overload
Find the Mistake Medium
Question
This code has a type error. Find the mistake:
Code
function process(x: string): string;
function process(x: number): number;
function process(x: string | number): string | number {
return x;
}
const result = process(true);
Hint
Check what types the overloads accept vs what is being passed.
Explanation
The function overloads only accept string or number, but true (boolean) is passed. TypeScript errors: No overload matches this call. The implementation signature is not directly callable — only the overload signatures are. Fix: pass a string or number, or add a boolean overload.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.