Skip to content

noImplicitAny: parameter implicitly has any

Quick summary

Your function parameter has no type annotation — TypeScript infers 'any' and reports an error when noImplicitAny is enabled.

Why this happens

  • A function parameter is missing a type annotation and noImplicitAny is enabled in tsconfig

  • A callback parameter in a higher-order function is not typed, defaulting to any

  • A destructured parameter has no type annotation, and the inferred type is any

Minimal example

✗ Broken code
function process(data) { // error: Parameter 'data' implicitly has an 'any' type
  return data.map((x) => x * 2);
}
✓ Fixed code
function process(data: number[]): number[] {
  return data.map((x) => x * 2);
}

Adding an explicit type annotation (number[]) tells TypeScript the expected type, satisfying noImplicitAny and enabling type checking.

How to diagnose

  • Read the TS error: 'Parameter implicitly has an any type' and add a type annotation

  • Check tsconfig.json for noImplicitAny: true which enforces explicit typing

  • Look at the function signature and identify which parameter lacks a type annotation

How to fix

  • Add an explicit type annotation to the parameter: function foo(x: string) instead of function foo(x)

  • If the type is genuinely unknown, use 'unknown' instead of 'any' for safer type handling

  • For callbacks, type the parameters based on the expected function signature from the library

How to prevent

  • Always add type annotations to function parameters, especially in shared library code

  • Enable noImplicitAny in tsconfig to catch missing types early and maintain type safety

Related Resources

Related Glossary

Related Lessons

← Back to language