Skip to Content
typesTraverse

Traverse

See source on Github 

Recursively collects values reachable through a property key.

If TKey points to an iterable field (for example children), this type includes the current object and every nested item found by repeatedly traversing that same key.

Example

type TreeNode = { id: string; children: TreeNode[]; }; // TreeNode (root and descendants) type NodeInTree = Traverse<TreeNode, 'children'>;