Variable 'X' implicitly has an 'any' type
Error message
implicitly has an 'any' type
Quick summary
With noImplicitAny enabled, TypeScript errors when a variable or parameter has no type annotation and its type cannot be inferred, defaulting to any.
Why this happens
Function parameter without a type annotation
Variable declared without initialization or annotation
Destructuring without type annotations
Using
letwithout a value or type
Minimal example
function double(x) { return x * 2; } // x implicitly has anyfunction double(x: number): number { return x * 2; }Add a type annotation to the parameter x.
How to diagnose
Check if the variable or parameter has a type annotation
Check if the variable is initialized with a value (for inference)
Look at the error location — it names the variable
How to fix
Add an explicit type annotation:
let x: numberInitialize the variable with a value:
let x = 0For function parameters, add type annotations
If any is intentional, use
: anyexplicitly
How to prevent
Enable noImplicitAny (part of strict mode)
Always annotate function parameters
Initialize variables when declaring them