The any Type

any Turns Off Type Checking

A value of type any can be anything, and TypeScript allows every operation on it: calling it, reading any property, assigning it anywhere. It is an escape hatch back to plain JavaScript.

Example

This compiles without a single error, but crashes at runtime because a number has no toUpperCase.

let data: any = 42;
data = "now a string";
data = { price: 100 };

let price: number = data.price; // no check
console.log(price);

data = 5;
console.log(data.toUpperCase());

Output

100
Uncaught TypeError: data.toUpperCase is not a function

Implicit any

Example

With strict (noImplicitAny), a parameter without a type is an error (TS7006) instead of silently becoming any.

function double(x) {
  return x * 2;
}
console.log(double(4));

Compiler output (tsc)

Line 1: error TS7006: Parameter 'x' implicitly has an 'any' type.