Q55: What are Recursive Type Aliases and how do you construct deeply nested JSON types?

Difficulty:MediumTopic:Recursive Types

A Recursive Type Alias references itself within its own type definition. Useful for hierarchical data structures like tree structures, AST nodes, or JSON payloads.

Type-Safe JSON Value Definition
type JSONValue =
  | string
  | number
  | boolean
  | null
  | JSONValue[]
  | { [key: string]: JSONValue };
💡 Recursively references JSONValue to type-check arbitrarily nested JSON structures.
Key Takeaways
  • Used to model recursive tree structures like JSON payloads.