Introduction
- 📺 TypeScript in 100 Seconds • 2 minute video by Fireship
- 📺 What is TypeScript? Why not just use JavaScript? • 6 minute video by Basarat Ali showing why TS is a safer version of JS
- 🧑🎓 Introduction to TypeScript • Free one-hour course by Scrimba that teaches you TypeScript through 21 interactive screencasts
- 📺 Let's Learn TypeScript! • 91 minute video by Orta Therox and Jason Lengstorf showing how to gradually add TypeScript to a JavaScript project
Built-in types
- 📺 TypeScript UNKNOWN and ANY types • 5 minute video by Basarat Ali clearly explaining the difference between
any
andunknown
- 📺 unknown, never, and void in TypeScript • 15 minute video by William Candillon showing a colleague practical use cases for
unknown
andnever
andvoid
- 📺 null vs. undefined in JavaScript and TypeScript • 6 minute video by Basarat Ali showing examples of
null
andundefined
values and how to check for them - 📺 TypeScript NEVER type - YouTube • 3 minute video by Basarat Ali showing how to use the
never
type to ensure all possible input types to a function have been handled - 📺 TypeScript TYPES vs INTERFACES • 7 minute video by Basarat Ali explaining the overlapping and unique features of types and interfaces and recommending to pick one as your default (he defaults to types) based on which one's unique features are more likely to be useful to you
- 📖 The Omit Helper Type in TypeScript • Article by Marius Schulz
Compiler options
- 📺 TypeScript alwaysStrict: Do you need it? • 3 minute video by Basarat Ali explaining the benefits of setting
alwaysStrict
totrue
- 📺 Why you should use allowUnreachableCode in TypeScript • 3 minute video by Basarat Ali explaining the benefits of setting
allowUnreachableCode
tofalse
Conditional types
- 📺 Conditional Types, TypeScript's most POWERFUL feature • 4 minute video by Basarat Ali using the example of a
typeName
helper to demonstrate how conditional types work and why you can think of them as functions that compute an output (a specific type) based on an input (a generic type) - 📺 TypeScripts amazing INFER Keyword • 3 minute video by Basarat Ali showing how to use the
infer
keyword inside a conditional type to get the type name of the generic argument that was passed in
Generic types
- 📺 Why Generics? • 3 minute video by Basarat Ali showing how generics help in cases where a structure accepts alternating types of inputs and outputs
Literal types
- 📺 Most common TypeScript literal types error • 4 minute video by Basarat Ali explaining how to reassure TS that a string or number is a valid member of a literal type
Special types
- 📺 Lookup Types - one of the first super powers of TypeScript • 3 minute video by Basarat Ali showing how lookup types can clean up your code and prevent typos by using a larger root type as the source of truth for smaller types
- 📺 What are TypeScript MAPPED Types and how to use them Effectively • 4 minute video by Basarat Ali using the example of creating a readonly version of an existing type to demonstrate how a mapped type is created by mapping over the properties of an existing type and modifying their definitions (similar to creating a new JS array by mapping over an existing array and returning a copy that transforms each item in some way)
- 📺 Mapped type MODIFIERS in TypeScript • 4 minute video by Basarat Ali showing how to use
+
,-
andPartial
to modify properties in a mapped type
Operators
- 📺 NULLISH operators ?. and ?? for JavaScript and TypeScript • 5 minute video by Basarat Ali showing how to use
?.
and??
- 📖 Nullish Coalescing: The ?? Operator in TypeScript • Article by Marius Schulz
Type guards
- 📺 TypeScript 2.7:
in
-based type guards • 2 minute video by Basarat Ali showing how to use the JSin
operator as a type guard that both TS and JS will understand
Narrowing
- Narrowing types at run-time with
typeof
andinstanceof
(really a JS thing, but useful in TS too) - Narrowing TS types with
arg is Type
type predicate functions- e.g.
function isString(arg: unknown): arg is string { return typeof arg === 'string'; }
- e.g.
function isFish(pet: Fish | Bird): pet is Fish { return (pet as Fish).swim !== undefined; }
(copied from docs)
- e.g.
- Narrowing TS types with
switch
statements - Narrowing TS types with function overloads (when the return type of a function changes as the type of its arguments change)
Inbox
- Override individual properties by omitting them first, then joining the new property definitions as a union type
- TypeScript Utility Types You Need to Know