← Theory library
TypeScript theory
Types, generics and safer contract bindings.
Practise in the Code Lab →Easy
- 1. Why TypeScriptA typed superset of JavaScript that compiles to plain JS.
- 2. Basic typesnumber, string, boolean, and the any escape hatch.
- 3. Arrays and tuplesTyped lists and fixed-length, fixed-type tuples.
- 4. Object types & interfacesDescribing the shape of objects.
- 5. Type aliases vs interfacesTwo ways to name a type, with overlapping but distinct powers.
- 6. Union and literal typesValues that can be one of several fixed shapes or values.
- 7. Functions: params, return types, optional & defaultTyping inputs, outputs, and flexible parameter lists.
- 8. EnumsNamed sets of constants, numeric or string-based.
- 9. null, undefined & strictNullChecksMaking absence of a value explicit and checked.
- 10. Type inference & contextual typingLetting the compiler figure out types for you.
- 11. Classes: fields, methods, constructorsObject-oriented building blocks with typed members.
- 12. Access modifiers & readonlypublic, private, protected, and immutable fields.
- 13. Interfaces implemented by classesContracts a class promises to fulfil.
- 14. Modules: import/exportSharing code between files with ES module syntax.
- 15. Working with arrays: map/filter/reduce, typedTyped transformations over collections.
- 16. Records and MapsTyped key-value structures.
- 17. Generics basicsWriting reusable code that stays type-safe.
- 18. Type assertions and castingTelling the compiler you know more than it does.
- 19. tsconfig.json essentialsConfiguring how the compiler checks and emits code.
- 20. Type narrowing with typeof, in, instanceofRuntime checks that refine union types.
Medium
- 21. Discriminated unionsTagged unions that make exhaustive handling safe.
- 22. never and exhaustiveness checksUsing the empty type to catch missing switch cases.
- 23. Optional chaining and nullish coalescingConcise, safe access to possibly-missing values.
- 24. Generic constraints (extends)Restricting what a generic type parameter can be.
- 25. Utility types: Partial, Pick, OmitBuilt-in generics that transform existing types.
- 26. Mapped typesGenerating new object types by transforming each property.
- 27. keyof and lookup typesDeriving key unions and indexed access types.
- 28. Function overloadsMultiple call signatures for one implementation.
- 29. Async/await and Promise<T>Typed asynchronous code without callback nesting.
- 30. Custom type guards (is)Writing your own narrowing functions.
- 31. Abstract classesBase classes that can't be instantiated directly.
- 32. Module augmentation & declaration filesDescribing the shape of untyped JS and extending existing types.
- 33. Working with JSON & unknownSafely handling data whose shape isn't guaranteed at compile time.
- 34. Index signaturesTyping objects with dynamic, unknown-in-advance keys.
- 35. Testing typed codeWriting assertions that verify both behaviour and types.
- 36. Web3 typing patterns: bigint & addressesModelling on-chain values precisely with the type system.
- 37. Error handling patternsTyped errors and Result-style alternatives to exceptions.
Hard
- 38. Conditional typesTypes that branch based on a type-level condition.
- 39. ReturnType, Parameters & other type queriesDeriving types from existing functions instead of duplicating them.
- 40. Template literal typesBuilding string types out of unions, like a compile-time string template.
- 41. Variance and function type compatibilityWhy some function types are assignable to others, and some aren't.
- 42. Branded/nominal typesSimulating nominal typing on top of structural types.
- 43. Decorators (experimental & stage-3)Annotating classes and members with reusable metadata/behaviour.
- 44. Type-safe event emittersMapping event names to their payload types.
- 45. Advanced generics: default & multiple constraintsGiving generics sensible defaults and combining constraints.
- 46. Structural typing pitfalls & excess property checksWhen structural typing surprises you, and when it protects you.
- 47. Performance-aware types & type-only importsKeeping compile times fast and bundles lean.
- 48. Designing a typed SDK layerWrapping a raw RPC/API client in strong, ergonomic types.
- 49. Building a mini type-safe validator (capstone groundwork)Combining guards, generics, and unions into a small validation toolkit.
- 50. Capstone: a typed on-chain event pipelineBringing generics, discriminated unions, and async together.