Any type

The any type allows you to opt-out of type-checking during compilation.

let notSure: any = 13;
notSure = "maybe a string instead";
notSure = false; // OK, guess it's a boolean

The any type is handy if you know some part of the type, but perhaps not all of it. For example, you may have an array but the array has a mix of different types:

const myList: any[] = [13, 'Blue Streak is a film from 1999', false];

Note: using any should be avoided when possible. By opting out of type-checking we lose out on the advantages of having a static type system, as discussed earlier.

Last updated