Table of Contents
Introduction
Code Infrastructure
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.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
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.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.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.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.Type Q&A
Mike answers student questions regarding if generics are more appropriately used in libraries compared to applications, if there is a standard for representing types in generics, and if Extract is an equivalent to the and operator.Inference with Conditional Types
Mike discusses using inference with conditional types to access sub-parts of type information within a larger type and walks through an example of using infer. The infer keyword can only be used within the condition expression of a conditional type.Inference Q&A
Mike answers a student's question regarding if the TypeScript team plans on making the type ConstuctorArg a standard type and discusses the benefits of creating package libraries of useful custom types.
Mapped Types
Indexed Access Types
Mike discusses indexed access types which provide a mechanism for retrieving parts of an array or object type via indices, how they work, and provides a few use case examples. How to access a more specific type from an array or object is also covered in this segment.Mapped Types
Mike discusses where mapped types name originates, the basics of mapped type, mapped type compared to index signature, and demonstrates the built in utility type Record. Mapped allow types to be defined in other types through a much more flexible version of an index signature.Advanced Mapped Types
Mike discusses using mapped types with indexed access types, demonstrates generalizing using type params, and allowing the type to work on anything and not just Window. A student's question regarding if mapped types extend from dictionary is also covered in this segment.Pick & Mapping Modifiers
Mike demonstrates using the built in utility type Pick and applying and removing modifiers with - and ?. A brief overview of modifying the built in utilities Partial, Required, and Readonly are also covered in this segment.Template Literal Types & Key Mapping
Mike discusses using the ECMAScript template literal syntax to create a template literal type, briefly discusses special types: UpperCase, LowerCase, Capitalize, and Uncapitalize, and walks through an example of key mapping to manipulate the keys as they are being mapped over. A brief demonstration of a package made using key mapping is also provided in this segment.Filtering Out Properties
Mike demonstrates how to filter properties out using Extract and a template literal type, filtering based on the value, a flawed approach to filtering, and walks through a more refined example to filter values by filtering the keys first. An in depth walk through of filtering values based on keys and conditions is also provided in this segment.Typing a Data Layer
Mike provides a practical exercise of properly typing a data layer with TypeScript to combine the topics discussed in this course and provides a walk through of the exercise.