TypeScript

good practices & pro techniques

Kamil Durkiewicz

Agenda

  1. Introduction
  2. General remarks
  3. Type algebra
  4. Classes
  5. Enums
  6. Currying
  7. Function / method overloading
  8. Generic types
  9. Summary
  10. Questions

TypeScript - facts

  • 1st release: 2012-10-01
  • Currently in version 2.3
  • Open source, maintained by Microsoft
  • Superset of ES6
  • Compiled to JavaScript
  • Only a language (without frameworks)

General remarks

Avoid dynamic typing

  • any
  • Function
  • bind, call, apply

Type algebra

Classes

Constructors and getters

Class is also an interface

Enums

Currying

Function / method overloading

Generic types

Don't forget about generics

Be careful with currying

keyof

Summary

  • Avoid dynamic typing
  • Learn and use syntactic sugars
  • Learn types algebra well
  • Don't spoil your generics

Questions?