O'Reilly logo
live online training icon Live Online training

Introduction to TypeScript programming

Yakov Fain

TypeScript is a compile-to-JavaScript language released by Microsoft as an open source project in 2012. A program written in TypeScript has to be transpiled into JavaScript before it can be executed in the browser or a stand-alone JavaScript engine. TypeScript allows you to use the latest ECMAScript syntax and compile it down to the older spec (e.g., ES5) supported by all browsers.

Join Expert Yakov Fain for a hands-on exploration of how to program in TypeScript. You’ll learn the latest TypeScript syntax constructs as well as how to turn your TypeScript code into JavaScript.

What you'll learn-and how you can apply it

By the end of this live, hands-on, online course, you’ll understand:

  • How to program in TypeScript using classes, interfaces, and more
  • How to compile and run the generated JavaScript in the browser or in a stand-alone JavaScript engine
  • The development-deployment process

And you’ll be able to:

  • Configure the process of transpiling TypeScript to JavaScript
  • See the benefits of optionally static typing
  • Use the main language constructs

This training course is for you because...

  • You’re a busy software developer trying to keep your web development skills up-to-date.
  • You work with JavaScript but want to write your code in TypeScript.
  • You’ve started using a framework that recommends writing code in TypeScript.

Prerequisites

  • A basic understanding of JavaScript syntax (ES5 edition) and HTML
  • A machine with the Chrome browser, the free Visual Studio Code editor, and the current version of Node.js installed

Recommended follow-up:

About your instructor

  • Yakov Fain is the co-author of the Amazon bestseller Angular 2 Development with TypeScript, as well as a number of other technical books on programming. Yakov works as a software architect at the IT consultancy Farata Systems and develops software products for the insurance industry. A Java Champion, he has taught multiple classes and workshops on web and Java-related technologies, presented at international conferences, and published more than a thousand blog posts (see https://yakovfain.com).

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Getting started with TypeScript (35 minutes)

  • Lecture: Programming in TypeScript; the TypeScript compiler; Visual Studio Code
  • Hands-on exercises: Use the TypeScript compiler; work with Visual Studio Code
  • Group discussion: Typical TypeScript workflows
  • Q&A

Basic and custom types (40 minutes)

  • Lecture: Basic type annotations; types in function declarations; union type; defining custom types; structural versus nominal type systems; types any, unknown, and user-defined type guards
  • Hands-on exercises: Use basic type annotations; use classes, interfaces, and type aliases; practice unions of custom types; apply types any, unknown, and user-defined guards
  • Group discussion: Using classes, interfaces, and type aliases
  • Q&A
  • Break (5 minutes)

Working with enums (15 minutes)

  • Lecture: String enums; const enums
  • Hands-on exercises: Write a function that uses string enums; rewrite function to use const enums
  • Q&A

Object-oriented programming with classes (40 minutes)

  • Lecture: Working with classes; class inheritance; access modifiers public, private, and protected; static variables and a singleton example; abstract classes; method overloading
  • Hands-on exercises: Write classes with and without the constructors; write the class Employee that’s inherited from Person; rewrite the classes to use access modifiers in the constructors; write a singleton using a private constructor and a static class member; write the class Employee that’s inherited from the abstract class Person
  • Q&A
  • Break (5 minutes)

Object-oriented programming with interfaces (30 minutes)

  • Lecture: Working with interfaces; enforcing the contract; extending interfaces
  • Hands-on exercises: Declare custom types using interfaces; write a class that implements an interface
  • Group discussion: Programming to interfaces

Wrap-up and Q&A (10 minutes)