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 3

WATCH Basarat Ali Syed's COURSE

Build Algorithms using Typescript

Build Algorithms using Typescript

Algorithms are the basic construction of the computer programs that you are writing every day. They take language syntax and th...

22 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

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

Refactor Services and Quick Fixes with Typescript 2.5

This lesson covers the Refactoring services and Quick fixes provided by Typescript 2.5

Akash Gutha
1:32

Type check JavaScript files using JSDoc and Typescript 2.5

Typescript 2.5 adds JSDoc type assertion support for javascript file via ts-check service.

Akash Gutha
1:31

Avoid Catching Errors with TypeScript 2.5 Optional Catch Clauses

Typescript 2.5 has brought a couple of interesting changes to the table. let's take a look at these new features and how to take advantage of these features. Optional catch clauses: TypeScript 2.5...

Akash Gutha
2:03

Create a TypeScript Library using typescript-library-starter

Creating a library is always a cumbersome process with lots of setup and decisions to make. TypeScript library starter makes this process very easy and automated, using latest in tech configs and l...

Alex Jover Morales
5:00

Use Prettier with TSLint without conflicts

Prettier is an amazing code formatting tool that has support for TypeScript. With Prettier, you don't need care about code formatting rules. TSLint is a static analysis tool that checks TypeScript ...

Alex Jover Morales
1:52

Understand lookup types in TypeScript

Lookup types, introduced in TypeScript 2.1, allow us to dynamically create types based on the property keys of an object. We'll use the function spyOn from Jest to illustrate how lookup types can t...

Alex Jover Morales
1:55

Deep Copy aka Clone objects using TypeScript

You can create copies of JavaScript objects by coping around properties e.g. const x = {foo: 123}; const y = { foo: x.foo }. However doing this manually for deep objects can be time consuming. In t...

Basarat Ali Syed
2:25

Create high quality npm packages using TypeScript

The TypeScript compiler makes it super easy to create high quality NodeJS packages that can be used with compile time safety in other TypeScript packages. Using JavaScript packages written in Type...

Basarat Ali Syed
3:54

Generics using TypeScript

In this lesson we cover the key reason why programming languages need generics. We then show how use them effectively with TypeScript. We show plenty of examples where generics prevent common progr...

Basarat Ali Syed
5:16

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

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

Browse all TypeScript lessons.

showing All 81 lessons...

Catching JavaScript Mistakes with TypeScript

P

TypeScript Up and Running in Seconds

P

Typescript Enums vs Booleans when Handling State

P

Introduction to Generics in Typescript

P

Understanding Generics with RxJS

P

Loading Compiled TypeScript Files in Browser with SystemJS

P

Configuring a New TypeScript Project

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

P

TypeScript - What Happens to Compiled Interfaces

P

Stopping a TypeScript Build When Errors Are Found

P

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

P

Using Lodash in TypeScript with Typings and SystemJS

P

TypeScript - Reflection and Decorator Metadata

P

TypeScript - Using Typings and Loading From node_modules

P

Installing TypeScript and Running the TypeScript Compiler (tsc)

Compiling TypeScript with WebStorm

P

TypeScript - Understanding Decorators

P

TypeScript - Definition Files

P

TypeScript - Generating Definition Files

P

Function Overloads in Typescript

P

Introduction to Static Typing

Creating a Class in TypeScript

P

Using Type Inference in TypeScript

Distinguishing between types of Strings in TypeScript

P

Using Assertion to Convert Types in TypeScript

P

Union Types and Type Aliases in TypeScript

P

Using Interfaces to Describe Types in TypeScript

P

Sharing Class Behavior with Inheritance in TypeScript

P

The Basics of Generics in TypeScript

P

Practical Generics in TypeScript

P

Simplify asynchronous callback functions using async/await

P

Catch unsafe use of "this" in TypeScript functions

P

Make usages of "this" safe in class methods

P

Install TypeScript declarations from npm

P

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

P

Bootstrap a TypeScript + React Project

P

Create stateless React components using TypeScript

P

Increase TypeScript's type safety with noImplicitAny

P

Create stateful React Components using TypeScript

P

Using TypeScript for pure JavaScript

P

Create a fluent API using TypeScript classes

P

Using ES6 and ESNext with TypeScript

P

Understand the FizzBuzz coding problem and its solution

Serialize objects to JSON

P

Getting started with Jest using TypeScript

P

Sort arrays in TypeScript

Generics using TypeScript

P

Create high quality npm packages using TypeScript

P

Case insensitive sorting for string arrays

P

Deep Copy aka Clone objects using TypeScript

P
typescript tutorial about Catching JavaScript Mistakes with TypeScript

Catching JavaScript Mistakes with TypeScript

5:13 typescript PRO

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

typescript tutorial about TypeScript Up and Running in Seconds

TypeScript Up and Running in Seconds

0:51 typescript PRO

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 Typescript Enums vs Booleans when Handling State

Typescript Enums vs Booleans when Handling State

3:49 typescript PRO

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 Introduction to Generics in Typescript

Introduction to Generics in Typescript

3:22 typescript PRO

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 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 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 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 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 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 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 - 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 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 - 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 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 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 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 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 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 - 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 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 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 Creating a Class in TypeScript

Creating a Class in TypeScript

4:00 typescript PRO

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 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 Distinguishing between types of Strings in TypeScript

Distinguishing between types of Strings in TypeScript

2:02 typescript PRO

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 Assertion to Convert Types in TypeScript

Using Assertion to Convert Types in TypeScript

2:09 typescript PRO

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 Union Types and Type Aliases in TypeScript

Union Types and Type Aliases in TypeScript

5:01 typescript PRO

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 Interfaces to Describe Types in TypeScript

Using Interfaces to Describe Types in TypeScript

3:32 typescript PRO

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 Sharing Class Behavior with Inheritance in TypeScript

Sharing Class Behavior with Inheritance in TypeScript

3:42 typescript PRO

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 The Basics of Generics in TypeScript

The Basics of Generics in TypeScript

2:07 typescript PRO

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 Practical Generics in TypeScript

Practical Generics in TypeScript

2:52 typescript PRO

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 Simplify asynchronous callback functions using async/await

Simplify asynchronous callback functions using async/await

1:48 typescript PRO

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 Catch unsafe use of "this" in TypeScript functions

Catch unsafe use of "this" in TypeScript functions

1:04 typescript PRO

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 Make usages of "this" safe in class methods

Make usages of "this" safe in class methods

0:59 typescript PRO

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 Install TypeScript declarations from npm

Install TypeScript declarations from npm

1:31 typescript PRO

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

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 PRO

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 Bootstrap a TypeScript + React Project

Bootstrap a TypeScript + React Project

5:54 typescript PRO

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 Create stateless React components using TypeScript

Create stateless React components using TypeScript

1:13 typescript PRO

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 Increase TypeScript's type safety with noImplicitAny

Increase TypeScript's type safety with noImplicitAny

2:24 typescript PRO

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 stateful React Components using TypeScript

Create stateful React Components using TypeScript

2:56 typescript PRO

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 Using TypeScript for pure JavaScript

Using TypeScript for pure JavaScript

2:15 typescript PRO

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 a fluent API using TypeScript classes

Create a fluent API using TypeScript classes

3:09 typescript PRO

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 ES6 and ESNext with TypeScript

Using ES6 and ESNext with TypeScript

2:49 typescript PRO

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 Understand the FizzBuzz coding problem and its solution

Understand the FizzBuzz coding 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 Serialize objects to JSON

Serialize objects to JSON

4:32 typescript PRO

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 Getting started with Jest using TypeScript

Getting started with Jest using TypeScript

3:17 typescript PRO

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 Sort arrays in TypeScript

Sort arrays in TypeScript

3:54 typescript

In this lesson we cover all the details of how to sort a list of items using TypeScript. There are a few things that will catch beginner developers off guard, such as the .sort method mutating your array, and how the .sort method doesn’t sort numbers how you’d expect. In this lesson we’ll be going over these gotcha’s and how to work around them.

We’ll also present a few tricks to make your sort logic more readable and maintainable using TypeScript.

typescript tutorial about Generics using TypeScript

Generics using TypeScript

5:16 typescript PRO

In this lesson we cover the key reason why programming languages need generics. We then show how use them effectively with TypeScript. We show plenty of examples where generics prevent common programming mistakes.

typescript tutorial about Create high quality npm packages using TypeScript

Create high quality npm packages using TypeScript

3:54 typescript PRO

The TypeScript compiler makes it super easy to create high quality NodeJS packages that can be used with compile time safety in other TypeScript packages.

Using JavaScript packages written in TypeScript can save you a lot of time digging around docs and then having to memorize the docs, in order to call the functions with the right spellings. This frees you up for a higher level of thinking and reasoning about logic and business requirements.

typescript tutorial about Case insensitive sorting for string arrays

Case insensitive sorting for string arrays

1:33 typescript PRO

We look at the default Array.prototype.sort behavior and discuss how you can do case insensitive string sorting. This isn’t as straightforward as it seems, Javascript by default sorts capitalized words before lowercase. In this lesson we’ll learn exactly how to deal with this behavior using TypeScript.

typescript tutorial about Deep Copy aka Clone objects using TypeScript

Deep Copy aka Clone objects using TypeScript

2:25 typescript PRO

You can create copies of JavaScript objects by coping around properties e.g. const x = {foo: 123}; const y = { foo: x.foo }. However doing this manually for deep objects can be time consuming. In this lesson we cover one way of deep copying simple objects in TypeScript.

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