Advanced Programming in TypeScript

During the training, participants will delve into the advanced mechanisms of the TypeScript type system. We will discuss practical scenarios related to designing interfaces, modeling complex types, building generic components, and creating error-resistant APIs. A strong emphasis will be placed on real examples from large projects, so that participants can consciously use typing to improve code quality and predictability. After the workshop, participants will have the skills to design code that is scalable, easy to maintain, and supports teams working on complex front-end and back-end applications.

Training program

Introduction to TypeScript

  1. What is TypeScript?
  2. Basics of configuring a TypeScript project:
  3. Installing TypeScript using npm
  4. Creating and configuring the `tsconfig.json` file (e.g., `strict`, `noImplicitAny`, `target`, `module`)
  5. Overview of TypeScript-to-JavaScript compilation and source maps
  6. TypeScript vs JavaScript

Type System in TypeScript

  1. Basic data types and their proper usage
  2. Complex types:
  3. Arrays, tuples, and enums
  4. Function types: describing function signatures, function overloading, `this` in functions, and arrow functions
  5. Objects and interfaces:
  6. How to define and use interfaces (`interface`) and types (`type`) to describe data structures
  7. Differences between `interface` and `type` — when to use which
  8. `readonly` and `const` — creating immutable objects
  9. Generics (generic types)
  10. Advanced types:
  11. Union Types and Intersection Types
  12. Conditional Types

Type Inference

  1. How TypeScript infers types
  2. Type Narrowing
  3. Control flow analysis and advanced narrowing constructs

Designing Types

  1. Creating readable and type-safe type definitions
  2. Modularization and reusability of types
  3. Interfaces and relationships between types

Object-Oriented Programming in TypeScript

  1. Defining classes and inheritance:
  2. Class fundamentals in TypeScript
  3. How TypeScript supports inheritance, polymorphism, and encapsulation
  4. Abstractions and interfaces:
  5. When to use abstract classes vs interfaces
  6. Examples of more advanced interface usage in object-oriented code
  7. Access modifiers:
  8. Controlling access to fields and methods with `public`, `protected`, and `private`
  9. Using `readonly` in classes to ensure immutability

Best Practices

  1. Safe error handling in TypeScript:
  2. How to write type-safe `try-catch` blocks
  3. Typing exceptions and creating precise error messages
  4. Asynchronous programming:
  5. Using types in async/await workflows
  6. Working with Promises and leveraging type safety in asynchronous operations
  7. Testing in TypeScript
  8. Typing external libraries