← TypeScript learning path
TypeScript · Module 2 of 10

Basic types

Annotate variables with string, number, boolean, arrays and more.

📖 Key ideas

  1. let name: string = "Asha";
  2. number, boolean, string are primitive types.
  3. Arrays: number[] or Array<number>.
  4. Tuples: [string, number].
  5. TypeScript infers many types automatically.
💡 Real-life example: Type annotations are labels on storage boxes: "only books here" stops you putting shoes inside.
AnnotationExplicit type after a colon
InferenceTypeScript guesses the type
TupleFixed-length typed array
anyTurns off type checking