TypeScript

TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

Any browser. Any host. Any OS. Open Source.

COURSES 2

WATCH John Lindquist's COURSE

Up and Running with TypeScript

Up and Running with TypeScript

The first question you ask after installing TypeScript is "What do I do now?" In this course you'll learn about using the TypeS...

14 lessons

WATCH Ari Picker's COURSE

Use Types Effectively in TypeScript

Use Types Effectively in TypeScript

TypeScripts purpose, the reason it exists, is to add a solid type system on top of ECMAScript 6+. JavaScript is a dynamically t...

10 lessons

Getting started with Jest using TypeScript

Jest is a painless JavaScript unit testing framework from Facebook. It is designed to be super easy to setup and is packed full of powerful features. In this lesson we see how easy it is to add to ...

Basarat Ali Syed
3:17

Serialize objects to JSON

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. Doing JSON serialization and de...

Basarat Ali Syed
4:32

Coding interview: FizzBuzz problem and its solution

The FizzBuzz problem is commonly presented as the lowest level of comprehension required to illustrate adequacy in computer programming. In this lesson you learn about the problem as well as its s...

Basarat Ali Syed
4:19

Using ES6 and ESNext with TypeScript

TypeScript is very particular about what is and isn't allowed in a TS file to protect you from common developer errors. By default if you set the compile target to ES5 it only allows you to use glo...

Basarat Ali Syed
2:49

Create a fluent API using TypeScript classes

You can create an easy to chain API using TypeScript classes. Learn about the this return type annotation and how it plays with function chaining and class inheritance.

Basarat Ali Syed
3:09

Using TypeScript for pure JavaScript

TypeScript can actually be used just as a JavaScript -> JavaScript Transpiler e.g. ES6 -> ES5. This allows you to easily maintain your old JavaScript code base along with potentially upliftin...

Basarat Ali Syed
2:15

Create stateful React Components using TypeScript

You can create stateful React Components in TypeScript by extending from the React.Component class. This parent class takes two generic parameters, Props and State. This lessons shows these gener...

Basarat Ali Syed
2:56

Increase TypeScript's type safety with noImplicitAny

TypeScript tries to infer as much about your code as it can. But sometimes there really is not enough context for it to infer reliably. If it tried to do such inference it would potentially result...

Basarat Ali Syed
2:24

Create stateless React components using TypeScript

You can create a stateless React component in TypeScript by just creating a function. But if you want to create high quality idiomatic React + TypeScript components you should use the React.State...

Basarat Ali Syed
1:13

Bootstrap a TypeScript + React Project

Setup a TypeScript + React project from scratch using webpack. Learn the reason behind every line that you need to type and become an expert.

Basarat Ali Syed
5:54

Use the never type to avoid code with dead ends using TypeScript

Programming language design does have a concept of bottom type that is a natural outcome as soon as you do code flow analysis. TypeScript does code flow analysis (😎) and so it needs to reliably rep...

Basarat Ali Syed
1:24

Install TypeScript declarations from npm

This lesson shows you how to acquire type declaration files for your TypeScript projects directly from npm.

Marius Schulz
1:31

Browse all TypeScript lessons.

showing All 45 lessons...

Getting started with Jest using TypeScript

Serialize objects to JSON

Coding interview: FizzBuzz problem and its solution

Using ES6 and ESNext with TypeScript

Create a fluent API using TypeScript classes

Using TypeScript for pure JavaScript

Create stateful React Components using TypeScript

Increase TypeScript's type safety with noImplicitAny

Create stateless React components using TypeScript

Bootstrap a TypeScript + React Project

Use the never type to avoid code with dead ends using TypeScript

Install TypeScript declarations from npm

Make usages of "this" safe in class methods

Catch unsafe use of "this" in TypeScript functions

Simplify asynchronous callback functions using async/await

Practical Generics in TypeScript

The Basics of Generics in TypeScript

Sharing Class Behavior with Inheritance in TypeScript

Using Interfaces to Describe Types in TypeScript

Union Types and Type Aliases in TypeScript

Using Assertion to Convert Types in TypeScript

Distinguishing between types of Strings in TypeScript

Using Type Inference in TypeScript

Creating a Class in TypeScript

Introduction to Static Typing

Function Overloads in Typescript

P

TypeScript - Generating Definition Files

P

TypeScript - Definition Files

P

TypeScript - Understanding Decorators

P

Compiling TypeScript with WebStorm

P

Installing TypeScript and Running the TypeScript Compiler (tsc)

TypeScript - Using Typings and Loading From node_modules

P

TypeScript - Reflection and Decorator Metadata

P

Using Lodash in TypeScript with Typings and SystemJS

P

TypeScript - Using Exclude and RootDir until File Globs Lands in 2.0.

P

Stopping a TypeScript Build When Errors Are Found

P

TypeScript - What Happens to Compiled Interfaces

P

Configuring TypeScript Which Files to Compile with "Files" and "OutDir"

P

Configuring a New TypeScript Project

Loading Compiled TypeScript Files in Browser with SystemJS

P

Understanding Generics with RxJS

P

Introduction to Generics in Typescript

Typescript Enums vs Booleans when Handling State

TypeScript Up and Running in Seconds

Catching JavaScript Mistakes with TypeScript

typescript tutorial about Getting started with Jest using TypeScript

Getting started with Jest using TypeScript

3:17 typescript

Jest is a painless JavaScript unit testing framework from Facebook. It is designed to be super easy to setup and is packed full of powerful features. In this lesson we see how easy it is to add to your TypeScript project. This will be followed by a quick example application.

typescript tutorial about Serialize objects to JSON

Serialize objects to JSON

4:32 typescript

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

Doing JSON serialization and deserialization in JavaScript and TypeScript is super easy as it is a format essentially designed for this language. This lesson covers the JSON.stringify primitive provided by JavaScript runtimes.

typescript tutorial about Coding interview: FizzBuzz problem and its solution

Coding interview: FizzBuzz problem and its solution

4:19 typescript

The FizzBuzz problem is commonly presented as the lowest level of comprehension required to illustrate adequacy in computer programming.

In this lesson you learn about the problem as well as its solution in TypeScript. We will also cover some tricks on approaching the problem and coding interview questions in general.

typescript tutorial about Using ES6 and ESNext with TypeScript

Using ES6 and ESNext with TypeScript

2:49 typescript

TypeScript is very particular about what is and isn't allowed in a TS file to protect you from common developer errors. By default if you set the compile target to ES5 it only allows you to use globally defined variables that were available in the ES5 time-frame. That said it is super easy to configure TypeScript to use ES6 or ESNext using the lib option.

We also cover how to make sure that these features work across the widest range of browsers using a simple polyfill.

typescript tutorial about  Create a fluent API using TypeScript classes

Create a fluent API using TypeScript classes

3:09 typescript

You can create an easy to chain API using TypeScript classes. Learn about the this return type annotation and how it plays with function chaining and class inheritance.

typescript tutorial about Using TypeScript for pure JavaScript

Using TypeScript for pure JavaScript

2:15 typescript

TypeScript can actually be used just as a JavaScript -> JavaScript Transpiler e.g. ES6 -> ES5. This allows you to easily maintain your old JavaScript code base along with potentially uplifting to a TypeSafe version using a single compiler.

typescript tutorial about Create stateful React Components using TypeScript

Create stateful React Components using TypeScript

2:56 typescript

You can create stateful React Components in TypeScript by extending from the React.Component class. This parent class takes two generic parameters, Props and State.

This lessons shows these generic parameters and React.Component in action

typescript tutorial about Increase TypeScript's type safety with noImplicitAny

Increase TypeScript's type safety with noImplicitAny

2:24 typescript

TypeScript tries to infer as much about your code as it can.

But sometimes there really is not enough context for it to infer reliably. If it tried to do such inference it would potentially result in more nuisance than help. So instead it infers the type any. This type can catch people off guard as it provides very little type safety. Fortunately TypeScript has a flag to make it easier to catch such unsafe code at development time.

typescript tutorial about Create stateless React components using TypeScript

Create stateless React components using TypeScript

1:13 typescript

You can create a stateless React component in TypeScript by just creating a function.

But if you want to create high quality idiomatic React + TypeScript components you should use the React.StatelessComponent interface. This is demonstrated in the video.

typescript tutorial about Bootstrap a TypeScript + React Project

Bootstrap a TypeScript + React Project

5:54 typescript

Setup a TypeScript + React project from scratch using webpack. Learn the reason behind every line that you need to type and become an expert.

typescript tutorial about Use the never type to avoid code with dead ends using TypeScript

Use the never type to avoid code with dead ends using TypeScript

1:24 typescript

Programming language design does have a concept of bottom type that is a natural outcome as soon as you do code flow analysis. TypeScript does code flow analysis (😎) and so it needs to reliably represent stuff that might never happen. This is what the never type is all about.

typescript tutorial about Install TypeScript declarations from npm

Install TypeScript declarations from npm

1:31 typescript

This lesson shows you how to acquire type declaration files for your TypeScript projects directly from npm.

typescript tutorial about Make usages of "this" safe in class methods

Make usages of "this" safe in class methods

0:59 typescript

this is determined by how you call a function. To write class methods that can always safely use this you can use the TypeScript property initializer syntax along with arrow functions.

typescript tutorial about Catch unsafe use of "this" in TypeScript functions

Catch unsafe use of "this" in TypeScript functions

1:04 typescript

this is probably the most tricky thing to use in JavaScript and therefore TypeScript. Fortunately there is a TypeScript compiler flag noImplicit this that can help catch unsafe usages so beginners don't get caught off guard.

typescript tutorial about Simplify asynchronous callback functions using async/await

Simplify asynchronous callback functions using async/await

1:48 typescript

Learn how to write a promise based delay function and then use it in async await to see how much it simplifies code over setTimeout.

Lets say you want to call a function after 1s, 2s, 3s. You can use setTimeout, or you can wrap it up into a simple delay function that works with async/await

typescript tutorial about Practical Generics in TypeScript

Practical Generics in TypeScript

2:52 typescript

Typescript generics are great for writing code that accepts any type. How do we write code that doesn’t accept any type, but instead accepts a range of types? In this lesson we learn how to use generic classes, interfaces and constraints to be more specific with our Typescript generics.

typescript tutorial about The Basics of Generics in TypeScript

The Basics of Generics in TypeScript

2:07 typescript

It can be painful to write the same function repeatedly with different types. Typescript generics allow us to write 1 function and maintain whatever type(s) our function is given. This lesson covers syntax and a basic use case for Typescript generics.

typescript tutorial about Sharing Class Behavior with Inheritance in TypeScript

Sharing Class Behavior with Inheritance in TypeScript

3:42 typescript

Typescript classes make inheritance much easier to write and understand. In this lesson we look into how to set up inheritance with Typescript classes, extends and super.

typescript tutorial about Using Interfaces to Describe Types in TypeScript

Using Interfaces to Describe Types in TypeScript

3:32 typescript

It’s easy to pass the wrong value to a function. Typescript interfaces are great because they catch errors at compile time or in an IDE. In this lesson we’ll learn how to describe a type shape with Typescript interfaces.

typescript tutorial about Union Types and Type Aliases in TypeScript

Union Types and Type Aliases in TypeScript

5:01 typescript

Sometimes we want our function arguments to be able to accept more than 1 type; e.g. a string or an array. This lesson will show us how to assign more than 1 type to a variable with Typescript union types and type aliases.

typescript tutorial about Using Assertion to Convert Types in TypeScript

Using Assertion to Convert Types in TypeScript

2:09 typescript

Sometimes the compiler needs help figuring out a type. In this lesson we learn how to help out the compiler with Typescript type assertion.

typescript tutorial about Distinguishing between types of Strings in TypeScript

Distinguishing between types of Strings in TypeScript

2:02 typescript

In JavaScript, many libraries use string arguments to change behavior. In this lesson we learn how Typescript catches string related errors at compile time by assigning a string literal as a type.

typescript tutorial about Using Type Inference in TypeScript

Using Type Inference in TypeScript

2:52 typescript

This lesson explains how the Typescript compiler uses inference to guess what types we’re using, so we don’t have to annotate all the things.

typescript tutorial about Creating a Class in TypeScript

Creating a Class in TypeScript

4:00 typescript

Typescript classes make traditional object oriented programming easier to read and write. In this lesson we learn about class syntax, what the constructor is and some interesting variable features.

typescript tutorial about Introduction to Static Typing

Introduction to Static Typing

1:39 typescript

This is a basic introduction to static typing with Typescript.
In this lesson we will learn about simple types in TypeScript.

typescript tutorial about Function Overloads in Typescript

Function Overloads in Typescript

3:46 typescript PRO

It's common in Javascript for functions to accept different argument types and to also return different types. In this lesson we learn how to 'teach' Typescript about these dynamic functions so that we can still benefit from the powerful static type analysis.

typescript tutorial about TypeScript - Generating Definition Files

TypeScript - Generating Definition Files

2:41 typescript PRO

TypeScript allows you to generate definition files for your own libraries. This lesson shows you how to organize your project and generate the definition files so that others projects can use your library with TypeScript.

typescript tutorial about TypeScript - Definition Files

TypeScript - Definition Files

5:51 typescript PRO

TypeScript definition files can be an extremely confusing topic to tackle due to the sheer variety and of features and libraries they need to cover. This lesson helps you understand definition files, how they're used, and where to find them based on many different scenarios.

typescript tutorial about TypeScript - Understanding Decorators

TypeScript - Understanding Decorators

3:23 typescript PRO

Decorators are a feature of TypeScript that are becoming more and more common in many major libraries. This lesson walks you through what decorators are and how to create your own.

typescript tutorial about Compiling TypeScript with WebStorm

Compiling TypeScript with WebStorm

1:31 typescript PRO

As long as you have a properly configured .tsconfig, most tooling can just run tsc behind the scenes to build your project. This lesson shows how WebStorm includes a nice interface for reporting and navigating to the errors and will continuously run your TypeScript build for you.

typescript tutorial about Installing TypeScript and Running the TypeScript Compiler (tsc)

Installing TypeScript and Running the TypeScript Compiler (tsc)

1:59 typescript

This lesson shows you how to install TypeScript and run the TypeScript compiler against a .ts file from the command line.

typescript tutorial about TypeScript - Using Typings and Loading From node_modules

TypeScript - Using Typings and Loading From node_modules

4:44 typescript PRO

Using TypeScript when installing packages from npm often requires you to install related definition files. This lesson shows you how to use typings to install es6-shim then how to configure SystemJS to load from node_modules.

typescript tutorial about TypeScript - Reflection and Decorator Metadata

TypeScript - Reflection and Decorator Metadata

5:59 typescript PRO

TypeScript allows you to emit decorator metadata which enables more powerful features through reflection. This lesson show you how decorators and reflection fit together and how to configure your own decorators to use reflection.

typescript tutorial about Using Lodash in TypeScript with Typings and SystemJS

Using Lodash in TypeScript with Typings and SystemJS

3:38 typescript PRO

One of the most confusing parts of getting started with TypeScript is figuring out how to use all the libraries that you know and love from JavaScript. This lesson walks you through including Lodash in your project, installing Lodash definition files, and then properly loading Lodash with SystemJS.

typescript tutorial about TypeScript - Using Exclude and RootDir until File Globs Lands in 2.0.

TypeScript - Using Exclude and RootDir until File Globs Lands in 2.0.

1:48 typescript PRO

Files globs will be available in TypeScript 2.0, so in the meantime, we need to use "exclude" and "rootDir" to configure which files to load. This lesson shows how to switch from "files" to "exclude".

typescript tutorial about Stopping a TypeScript Build When Errors Are Found

Stopping a TypeScript Build When Errors Are Found

0:58 typescript PRO

TypeScript will always compile even if there are ridiculous errors in your project. This lesson shows how to configure your .tsconfig with "noEmitOnError" so that no files are output if tsc reports an error.

typescript tutorial about TypeScript - What Happens to Compiled Interfaces

TypeScript - What Happens to Compiled Interfaces

3:14 typescript PRO

This lesson covers using your first TypeScript Interface and what happens to the Interface when it is compiled down to JavaScript.

typescript tutorial about Configuring TypeScript Which Files to Compile with "Files" and "OutDir"

Configuring TypeScript Which Files to Compile with "Files" and "OutDir"

1:24 typescript PRO

This lesson shows how to configure the .tsconfig so you only compile the .ts files you want. It then shows how to configure which directory you'd like to compile the files to using "outDir".

typescript tutorial about Configuring a New TypeScript Project

Configuring a New TypeScript Project

0:52 typescript

This lesson walks you through creating your first .tsconfig configuration file which will tell the TypeScript compiler how to treat your .ts files.

typescript tutorial about Loading Compiled TypeScript Files in Browser with SystemJS

Loading Compiled TypeScript Files in Browser with SystemJS

5:00 typescript PRO

TypeScript outputs JavaScript, but what are you supposed to do with it? This lesson shows how to take the output and use SystemJS as the module loader so that you can use the files in your browser.

typescript tutorial about Understanding Generics with RxJS

Understanding Generics with RxJS

7:12 typescript PRO

Libraries such as RxJS use generics heavily in their definition files to describe how types flow through different interfaces and function calls. We can provide our own type information when we create Observables to enable all of the auto-complete & type-safety features that you would expect from Typescript. This can be achieved with minimal annotations thanks to the power of generics.

typescript tutorial about Introduction to Generics in Typescript

Introduction to Generics in Typescript

3:22 typescript

If Typescript is the first language in which you've encountered generics, the concept can be quite difficult to understand. We skip the lecture in this lesson and dive straight into a real-world use-case that is guaranteed to help you understand the need for generics.

typescript tutorial about Typescript Enums vs Booleans when Handling State

Typescript Enums vs Booleans when Handling State

3:49 typescript

Handling state with Typescript enums, instead of booleans, is preferred because:
- Enums are more readable
- Enums can have as many states as you need while booleans only have 2
- You only need to keep track of state with 1 variable when using enums

typescript tutorial about TypeScript Up and Running in Seconds

TypeScript Up and Running in Seconds

0:51 typescript

It’s easy to get up and running with TypeScript, a strongly-typed superset of JavaScript. We’ll cover:
- installing the compiler with Node.js
- compiling TypeScript to JavaScript
- auto-watching source files for changes
- fixing code errors found by TypeScript

typescript tutorial about Catching JavaScript Mistakes with TypeScript

Catching JavaScript Mistakes with TypeScript

5:13 typescript

The TypeScript compiler is a powerful tool which catches mistakes even in vanilla JavaScript. Try it online at the TypeScript Playground, zero setup required.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?