Special Sponsor:PromptBuilder— Fast, consistent prompt creation powered by 1,000+ expert templates.
Make your Product visible here.Contact Us

Home/TypeScript Errors/TS7006

TS7006

Parameter 'X' implicitly has an 'any' type

TypeScript TS7006 fires when a function parameter has no type annotation and TypeScript cannot infer its type from context, forcing it to implicitly be 'any'. This error only appears with noImplicitAny or strict mode enabled.

Why This Happens

You wrote a function without type annotations for its parameters, and TypeScript can't infer the type from how the function is used. With noImplicitAny: true, TypeScript requires explicit types on parameters that can't be inferred.

Code That Triggers TS7006

// TS7006 examples
function double(x) {
  return x * 2;
}
// Error: Parameter 'x' implicitly has an 'any' type

const multiply = (a, b) => a * b;
// Error: Parameter 'a' implicitly has an 'any' type
// Error: Parameter 'b' implicitly has an 'any' type

// Also in callbacks
[1, 2, 3].forEach(item => {
  // 'item' is inferred — no error here because TypeScript knows it's number
});

// But not when the callback type isn't provided
someUnknownFunction(item => {
  console.log(item.name); // Error: 'item' implicitly has an 'any' type
});

How to Fix TS7006

Option 1: Add explicit type annotations

function double(x: number): number {
  return x * 2;
}

const multiply = (a: number, b: number): number => a * b;

Option 2: Type the callback inline

someFunction((item: User) => {
  console.log(item.name); // OK
});

Option 3: Disable noImplicitAny (not recommended for new projects)

// tsconfig.json
{
  "compilerOptions": {
    "noImplicitAny": false // turns off the rule, but reduces type safety
  }
}

Frequently Asked Questions — TS7006

What does TS7006 mean?

TS7006 means a function parameter has no type annotation and TypeScript can't infer it, so it would default to 'any'. With noImplicitAny enabled, TypeScript requires you to be explicit about types.

Why does TS7006 appear after enabling strict mode?

strict: true in tsconfig.json enables noImplicitAny, which disallows implicit any types on parameters. You need to add type annotations to all function parameters that TypeScript can't infer.

TS7006 in callbacks — how to fix?

Type the callback parameter explicitly: arr.map((item: User) => item.name). Or type the outer function so TypeScript can infer the callback's parameter type.

Why don't forEach/map callbacks trigger TS7006?

When you call array methods on a typed array, TypeScript can infer the callback's parameter type from the array's element type. TS7006 only fires when TypeScript genuinely can't infer the type.

Is it OK to type parameters as 'any' to suppress TS7006?

It's explicit, so TS7006 disappears, but it turns off type checking for that parameter. Better to use the actual type. Use unknown instead of any if you don't know the type — it's safer.

Convert JavaScript to TypeScript automatically

Paste your JS code and get type-annotated TypeScript — including fixes for common type errors — in seconds.

Try the converter →

Other TypeScript Errors

From the blog

View all →