TS7006
TypeScriptERRORNotableConfigurationHIGH confidence

Parameter implicitly has an 'any' type

What this means

A function parameter has no type annotation, and its type cannot be inferred. This error appears when the 'noImplicitAny' compiler option is enabled.

Why it happens
  1. 1Forgetting to add a type annotation to a function parameter.
  2. 2The compiler is unable to infer the parameter's type from its usage within the function.
  3. 3Defining a function parameter without a type and without a default value.
How to reproduce

A function parameter is missing a type annotation.

trigger — this will error
trigger — this will error
function greet(name) {
  console.log("Hello, " + name);
}

expected output

error TS7006: Parameter 'name' implicitly has an 'any' type.

Fix 1

Add a type annotation

WHEN The type of the parameter is known.

Add a type annotation
function greet(name: string) {
  console.log("Hello, " + name);
}

Why this works

Explicitly declaring the type enables type checking and improves code clarity.

Fix 2

Explicitly use 'any'

WHEN The parameter can truly be of any type and you want to be explicit about it.

Explicitly use 'any'
function logValue(value: any) {
  console.log(value);
}

Why this works

Using 'any' explicitly signals that the lack of type safety is intentional.

What not to do

Disable 'noImplicitAny' in tsconfig.json

This is a core feature of TypeScript. Disabling it reduces type safety across the entire project.

Sources
Official documentation ↗

microsoft/TypeScript src/compiler/diagnosticMessages.json

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All TypeScript errors