typescript

Intermediate TypeScript

Mike North
Mike North
LinkedIn
2 hours,48 minutes CC

Learn to type some of the more tricky TypeScript challenges found in large codebases, such as declaration files, generics, and transforming types. You’ll learn to keep yourself and your team unblocked by learning to diagnose common problems quickly. By taking this course, you'll grow from being a contributor to a TypeScript codebase to being on the path to becoming "the TypeScript expert" for your team.

This course and others like it are available as part of our Frontend Masters video subscription.

Published: August 4, 2021
Get Unlimited Access Now

Table of Contents

Introduction

demo1
00:00:00 - 00:04:16

Introduction

Mike North introduces the course by discussing goals of this course, prerequisites, and a brief workshop setup. A brief overview of other TypeScript courses on Frontend Masters and their relation to this course is also provided in this segment.

Code Infrastructure

demo1
00:04:17 - 00:14:59

Declaration Merging

Mike discusses stacking types and values on an identifier, how to understand what is attached to an identifier, and what a namespace is. A walk through of applying type and value tests to a class and how classes relate to declaration merging is also provided in this segment.

demo1
00:15:00 - 00:27:07

Modules & CJS Setup

Mike discusses ES Module imports and exports, CommonJS Interop, how avoid ECMAScript errors, and importing outside of JavaScript and TypeScript. If the esModuleInterop and allowSyntheticDefaultImports compiler flags are enabled in order to satisfy ECMAScript errors, anyone who depends on those types will also have to enable them.

Conditional Types

demo1
00:27:08 - 00:35:05

Type Queries

Mike discusses how to obtain a type from a value with the type queries keyof and typeof. The query keyof obtains the type representing all property keys on a given interface while typeof extracts a type from a value. An example for each of these type queries provided in this segment.

demo1
00:35:06 - 00:39:50

Conditional Types

Mike demonstrates the syntax similarities between JavaScript ternary operators and conditional types. A walk through of each part of a conditional type is also covered in this segment.

demo1
00:39:51 - 00:49:06

Conditional Types Practice

Mike provides a short exercise to practice with the extends keyword by determining whether a conditional type will evaluate to true or false. A walk through of each example and a student question regarding the modern set theory limitations are also covered in this segment.

demo1
00:49:07 - 00:57:16

Extract & Exclude

Mike discusses the built-in utility types Extract and Exclude, walks through an example of each utility type, and describes how each utility type works. Exclude is the opposite of Extract, in that it’s useful for obtaining the part of a type that’s not assignable to some other type.