โ† 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