Advanced TypeScript types for fun and reliability

Rate this content
Bookmark

If you're looking to get the most out of TypeScript, this workshop is for you! In this interactive workshop, we will explore the use of advanced types to improve the safety and predictability of your TypeScript code. You will learn when to use types like unknown or never. We will explore the use of type predicates, guards and exhaustive checking to make your TypeScript code more reliable both at compile and run-time. You will learn about the built-in mapped types as well as how to create your own new type map utilities. And we will start programming in the TypeScript type system using conditional types and type inferring.


Are you familiar with the basics of TypeScript and want to dive deeper? Then please join me with your laptop in this advanced and interactive workshop to learn all these topics and more.


You can find the slides, with links, here: http://theproblemsolver.nl/docs/ts-advanced-workshop.pdf
And the repository we will be using is here: https://github.com/mauricedb/ts-advanced

This workshop has been presented at TypeScript Congress 2022, check out the latest edition of this JavaScript Conference.

FAQ

The main goal of the workshop is to demonstrate various TypeScript features which attendees might or might not be familiar with. These include setting strict types, validating data at runtime and compile time, creating custom type mappings, and exploring type predicates and assertions among other advanced topics.

Participants need a Node runtime, npm installed, and preferably Node version 12.2 or later. A basic understanding of TypeScript is also recommended to follow the workshop effectively.

The workshop is designed to be interactive with participants writing a lot of code themselves, getting involved in breakout rooms for discussions, and performing tasks in groups. This approach helps simulate a real-life coding environment and tackles problem-solving in a collaborative setting.

Zot is used in the workshop to validate data at boundaries, such as inputs from users or data fetched from APIs. It ensures that the data matches expected types and structures, promoting reliability and reducing runtime errors in applications.

Beyond the basic strict mode, the workshop explores several strict settings that are not covered by TypeScript's default strict mode. These include 'noUncheckedIndexedAccess', 'noUnusedLocals', and 'noImplicitReturns', which provide stricter type checking and help catch potential bugs in code.

Maurice de Beijer
Maurice de Beijer
116 min
24 May, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This workshop covers advanced TypeScript types and features such as strict mode, type validation, error handling, and type mappings. It explores techniques to improve code reliability and prevent errors. Topics include treating elements as never being null, deriving TypeScript type definitions from schemas, using read-only types to enforce immutability, and utilizing type mappings like omit and pick. The workshop also emphasizes the importance of type safety, type readability, and exhaustiveness testing. Overall, it provides practical insights to enhance the reliability and type safety of TypeScript code.
Video transcription and chapters available for users with access.