Skip to main content
TypeScript Bug Hunt Easy +10 XP

Missing Type Annotation

This function has a type error.

TypeScriptFind the bug
1function add(a, b) {
2 return a + b;
3}
The bug is on line 1

Select the correct fix

Show answer and explanation

Answer: Add : number type to both parameters

TypeScript requires type annotations for parameters. Without them, they default to 'any' in strict mode.

Hint: TypeScript needs to know the types.

What this challenge tests

Bug Hunt in TypeScript: types, functions.

Related challenges