FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Useful TypeScript generics for tree structures
How-ToWeb Development

Useful TypeScript generics for tree structures

via Dev.toMarat Sabitov1mo ago

Developers are surrounded by hierarchies of objects, such as the DOM tree, React component tree, and NPM dependency tree. Tree-like data structures are quite common in code, and reliable Typescript types make working with them more confident. In this article, I want to share with you some generics that benefit me the most. Deep partial Sometimes we are willing to provide default values for all parameters of a third-party function, even nested ones, so they are all optional. In that case DeepPartial type is helpful: type DeepPartial < T > = T extends object ? { [ P in keyof T ]?: DeepPartial < T [ P ] > ; } : T ; type InitialType = { header : { size : ' sm ' | ' md ' | ' lg ' ; color : ' primary ' | ' secondary ' ; nav : { align : ' left ' | ' right ' ; fontSize : number ; } }; footer : { fixed : boolean ; links : { max : 5 | 10 ; nowrap : boolean ; } } }; type ResultType = DeepPartial < InitialType > ; /* type ResultType = { header?: { size?: "sm" | "md" | "lg" | undefined; color?: "pr

Continue reading on Dev.to

Opens in a new tab

Read Full Article
22 views

Related Articles

Gate.io vs KuCoin — Which Crypto Exchange Is Better? (2026)
How-To

Gate.io vs KuCoin — Which Crypto Exchange Is Better? (2026)

Dev.to Beginners • 5h ago

How to Build a Real Multi-Agent Engineering Workflow With oh-my-claudecode
How-To

How to Build a Real Multi-Agent Engineering Workflow With oh-my-claudecode

Medium Programming • 6h ago

Clean Code Principles Every Software Engineer Should Follow
How-To

Clean Code Principles Every Software Engineer Should Follow

Medium Programming • 7h ago

The Real Cost of Abstractions in .NET
How-To

The Real Cost of Abstractions in .NET

Medium Programming • 8h ago

Stop Learning Frameworks — You’re Wasting Your Time
How-To

Stop Learning Frameworks — You’re Wasting Your Time

Medium Programming • 9h ago

Discover More Articles