← TypeScript learning pathTypeScript · Module 2 of 10
Basic types
Annotate variables with string, number, boolean, arrays and more.
📖 Key ideas
- let name: string = "Asha";
- number, boolean, string are primitive types.
- Arrays: number[] or Array<number>.
- Tuples: [string, number].
- 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