TypeScript 4.1’s Advanced Mapped Types

TypeScript 4.1’s Advanced Mapped Types

In this article, we are going to explore some of the features introduced in 4.1 and how you can apply them to mapped types.

A look at recursive conditional types, template literal types, and more

If you’ve ever read any of my TypeScript articles, you’ll know that I’m a big fan of mapped types. They’re my all-time favorite feature because they’re fun and easy to use once you get the hang of them.

Mapped types landed in TypeScript version 2.1, and since then, they’ve seen more and more improvements. If you don’t know what mapped types are, I suggest reading my previous article.

In this article, we are going to explore some of the features introduced in 4.1 and how you can apply them to mapped types.

TypeScript 4.1

TypeScript 4.1 was released recently and there are many goodies in it. In this article, we will especially focus on:

  • Recursive conditional types
  • Template literal types
  • Key remapping in mapped types
  • Checked indexed accesses

We will dive deep into those and see what new things we can do.

I strongly recommend using the TypeScript playground to best follow along with this article. You can tweak all the configurations and even switch the TypeScript version. It’s a must-use tool for newcomers, as it will also show the output of the JS code.

programming typescript web-development javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

TypeScript Tutorial For JavaScript Developers - TypeScript Basics

TypeScript Tutorial For JavaScript Developers - TypeScript Basics. I will show you guys 4 example of JavaScript code, and how to convert it to TypeScript. This is a typescript beginners tutorial.

What is TypeScript? Why TypeScript? and Why Not TypeScript?

TypeScript extends JavaScript by adding Types. There are many great reasons to switch to TypeScript. Especially if your team uses JavaScript. There are some reasons to not use TypeScript as there are with any language or framework.

Why Web Development is Important for your Business

With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...

Important Reasons to Hire a Professional Web Development Company

    You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...

What, Why, and How of Typescript for JavaScript Developers

This guide gives an introductory but comprehensive guide to Typescript any Javascript developer would need to get started with it. Learn the what, why and how of Typescript, an introduction for beginners.