A deep dive into TypeScript's `infer` keyword and recursive types, using them to build a custom schema language parsed from template literal strings. The tutorial walks through parsing primitives, objects with multiple properties, arrays, optional fields, and whitespace handling — all at the type level. Key techniques include recursive type splitting, bracket balancing via character counting in tuples, and merging arrays of object types. The result is a `compileSchema` function that preserves full type information from a string template.
Table of contents
IntroductionDon’t we lose all type information?Objects with multiple propertiesObject propertiesParsing a propertyArray propertiesOptional valuesWhitespaceOutroSort: