Course contentsShow
← TypeScript
Lesson 179 of 1,7964. Type InferenceFree lesson

Implicit any from Untyped Parameters

Why function parameters without annotations default to any and how this defeats type safety silently.

Implicit any from Untyped Parameters

You'll learn: Why forgetting to type function parameters creates a silent hole in your type safety.

The Silent Safety Killer

When you write a function but forget to add type annotations to its parameters, TypeScript doesn't stop you—it assigns them the any type by default. This is implicit any, and it's dangerous because your code looks like it's typed but actually has zero type checking on those parameters.

function greet(name) {  // name is implicitly 'any'
  return `Hello, ${name.toUppercase()}`;  // Typo! Should be toUpperCase()
}

greet(42);  // TypeScript allows this!

Both lines are disasters: name could be anything (even a number), and the typo in toUppercase() goes unnoticed. TypeScript can't help you because it doesn't know what name should be.

Why This Defeats Type Safety

The entire point of TypeScript is catching mistakes before runtime. When parameters are implicitly any, you lose:

  • Type checking: Any value can be passed in
  • Autocomplete: Your editor can't suggest properties
  • Error detection: Typos and wrong method calls slip through

This is why noImplicitAny exists in strict mode—it makes TypeScript error when you forget parameter types, forcing you to be explicit.

The Fix

Always annotate your parameters:

function greet(name: string) {
  return `Hello, ${name.toUpperCase()}`;
}

Now TypeScript protects you from both the typo and wrong argument types.

Key Takeaway: Untyped function parameters silently default to any, creating invisible holes in your type safety. Always annotate them explicitly.