3.1 The Any Type

The Any type is used to represent any JavaScript value. A value of the Any type supports the same operations as a value in JavaScript and minimal static type checking is performed for operations on Any values. Specifically, properties of any name can be accessed through an Any value and Any values can be called as functions or constructors with any argument list.

The any keyword references the Any type. In general, in places where a type is not explicitly provided and TypeScript cannot infer one, the Any type is assumed.

The Any type is a supertype of all types, and is assignable to and from all types.

Some examples:

  1. var x: any; // Explicitly typed
  2. var y; // Same as y: any
  3. var z: { a; b; }; // Same as z: { a: any; b: any; }
  4. function f(x) { // Same as f(x: any): void
  5. console.log(x);
  6. }