O'Reilly logo
live online training icon Live Online training

Introduction to TypeScript Programming

Yakov Fain

  • Join Yakov Fain for a hands-on exploration of how to program in TypeScript. In this course, you’ll learn the latest TypeScript syntax constructs as well as the process of turning your TypeScript code into JavaScript.

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

  • We assume you’re familiar with the JavaScript syntax, and we’ll cover the most important features of TypeScript as well as the workflow of compiling the 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 standalone 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 and want to write the code in TypeScript with further compilation into JavaScript.
  • You start using a framework that recommends writing code in TypeScript

Prerequisites

  • To gain the most from this class participants should understand the syntax of JavaScript (ES5 edition) and HTML.

Recommended preparation:

  • During this course, we’ll use the Chrome Browser, so the participants should have it installed.
  • Participants should install the free Visual Studio Code editor.
  • Participants should install the current version of Node.js.

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 (40 min)

  • Presentation: Why program in TypeScript
  • Discussion: Typical TypeScript workflows
  • Presentation: TypeScript compiler
  • Exercise: Using TypeScript compiler
  • Presentation: Getting familiar with Visual Studio Code
  • Exercise: Work with Visual Studio Code
  • Q&A

Basic and custom types (40 min)

  • Presentation: Basic type annotations
  • Exercise: using basic type annotations
  • Presentation: Types in function declarations
  • Presentation: The union type
  • Break: 5 min
  • Presentation: Defining custom types
  • Discussion: using classes, interfaces, and type aliases
  • Exercise: Using classes, interfaces, and type aliases
  • Presentation: Structural vs nominal type systems
  • Exercise: Unions of custom types
  • Presentation: Types any, unknown, and user-defined type guards
  • Exercise: Apply the types any, unknown, and user-defined type guards
  • Q&A

Working with enums (15 min)

  • Presentation: String enums
  • Exercise: Write a function that uses string enums
  • Presentation: const enums
  • Exercise: Re-write the function from the previous exercise to use const enums
  • Q&A

Object-oriented Programming with classes (40 min)

  • Presentation: Working with classes
  • Exercise: Writing classes with and without the constructors
  • Presentation: Getting familiar with class inheritance
  • Exercise: Write the class Employee that’s inherited from Person
  • Break: 5 min
  • Presentation: Access modifiers public, private, protected
  • Exercise: Re-write the classes from the previous exercise to use access modifiers in the constructors
  • Presentation: Static variables and a singleton example
  • Exercise: Write a singleton using a private constructor and a static class member
  • Presentation: Abstract classes
  • Exercise: Write the class Employee that’s inherited from the abstract class Person
  • Presentation: Method overloading
  • Q&A

Object-oriented Programming with interfaces (30 min)

  • Presentation: Working with interfaces
  • Exercise: Declare custom types using interfaces
  • Presentation: Enforcing the contract
  • Exercise: Write a class that implements an interface
  • Presentation: Extending interfaces
  • Discussion: Programming to interfaces
  • Q&A