Michael Hladky & Stefan Baumgartner

The Art and Craft of Type Development

Stop guessing object paths. Use recursive types and template literals to get full auto-completion and compile-time safety for any nested property.

The Art and Craft of Type Development
#1about 6 minutes

The challenge of typing deeply nested object properties

Manually creating function overloads for each level of object nesting is not a scalable or dynamic solution for property selection.

#2about 9 minutes

Setting up a playground for advanced type development

Isolate type development by using the TypeScript playground, a sample data object, and a declared function to focus solely on type signatures.

#3about 13 minutes

Recursively generating a union type for nested keys

Build a recursive helper type using string literals and conditional types to generate a union of all possible dot-notation paths for a nested object.

#4about 8 minutes

Inferring the return type from a string path

Use a recursive conditional type with the `infer` keyword to parse a dot-notation string and correctly determine the type of the selected nested property.

#5about 6 minutes

Recapping the workflow and current TypeScript limitations

The development process involves isolating the problem, using helper types, and understanding current limitations like variadic tuple types for dynamic argument lists.

Related jobs
Jobs that call for the skills explored in this talk.

test

Milly
Vienna, Austria

Intermediate

test

Milly
Vienna, Austria

Intermediate

Featured Partners

Related Articles

View all articles
TL
Thomas Limbüchler
What is TypeScript?
Since Angular 2 at the latest, TypeScript has been known to many. But what exactly can you do with it, and is it worth changing?Anyone who has worked with programming languages ​​such as Java or C# before will have noticed that JavaScript allows a su...
What is TypeScript?
CH
Chris Heilmann
Dev Digest 134 - Where pixels sing?
News and ArticlesWeAreDevelopers LIVE Data and Security Day is on Wednesday, 25/09/2024. Learn about OPC UA Updates, Best Practices for Using GitHub Secrets, Passwordless Web 1.5, Emerging AI Security Risks, Data Privacy in LLMs and get a chance to t...
Dev Digest 134 - Where pixels sing?
LM
Luis Minvielle
The Best Upcoming IT Webinars
Now that you already know what IT webinars are and how they can help you level up your professional appeal, you might want actually to get into one. Live tech webinars are one of the best ways to stay on top of the latest trends and tools because eit...
The Best Upcoming IT Webinars
CH
Chris Heilmann
Dev Digest 136 - No JS(on) of mine
News and ArticlesDouglas Crockford is our featured video, so let's talk about evolving JavaScript and all things JSON. Judicious JSON explains all the weird things in it, you can learn why it can be incredibly slow, people wonder what even is a JSON ...
Dev Digest 136 - No JS(on) of mine

From learning to earning

Jobs that call for the skills explored in this talk.