Overview
The TypeInfo generation system converts Microsoft API Extractor’s API model into a structured JSON format compatible with Mintlify’s<TypeTree open> component. The key challenge is fully recursive type expansion - extracting not just top-level properties, but all nested object structures with their complete documentation.
Architecture
Core Components
The TypeInfo generation pipeline consists of:TypeInfoGenerator (src/utils/TypeInfoGenerator.ts)
The main orchestrator responsible for:
- Loading API models from API Extractor output
- Recursively processing API items (interfaces, classes, type aliases)
- Resolving type references across the API model
- Converting to TypeTreeProperty-compatible format
- Generating both
.jsxand.d.tsfiles
ObjectTypeAnalyzer (src/utils/ObjectTypeAnalyzer.ts)
Utility for parsing complex TypeScript type strings:
- Parses inline object type literals
- Extracts nested properties, unions, intersections
- Handles generics and array types
- Returns structured
TypeAnalysisobjects
CacheManager (src/cache/)
Performance optimization layer:
- Caches parsed type strings (TypeAnalysisCache)
- Caches API item lookups (ApiResolutionCache)
- LRU eviction for memory management
The Recursive Type Resolution Algorithm
Problem Statement
Given a TypeScript interface like:Core Algorithm
The resolution happens in_extractNestedProperties():
Why Named Interfaces Are Critical
Bad (loses documentation):- Named references: Looks up in API model → gets full docs recursively
- Inline objects: Parses structure only → no property-level docs
Key Methods
_processProperty()
Converts an API Extractor property item to TypeInfo format:
_findApiItemByName()
Critical for type reference resolution:
- Nested namespace members
- Re-exported types from external packages
- Types in different entry points
_convertTypeAnalysisToString()
Converts parsed type structures back to readable type strings:
Output Generation
TypeInfo.jsx
JavaScript module with the complete type structure:TypeInfo.d.ts
TypeScript declaration for IDE autocomplete:Performance Considerations
Caching Strategy
The system uses two-level caching:-
Type Analysis Cache (ObjectTypeAnalyzer)
- Caches parsed type strings
- Key: raw type string
- Value: TypeAnalysis object
- Prevents redundant parsing of common types
-
API Resolution Cache (Future optimization)
- Could cache
_findApiItemByName()lookups - Currently uses
JSON.stringify()for keys (slow) - Opportunity for improvement with better key generation
- Could cache
Recursion Depth
The recursive algorithm naturally terminates because:
- TypeScript doesn’t allow circular type references at the value level
- Each recursion processes a unique API item
- Primitive types (string, number, etc.) end the recursion
Integration Points
MarkdownDocumenter
The TypeInfoGenerator is called fromMarkdownDocumenter._writeApiItemPage():
Configuration
TypeInfo generation is always enabled and runs automatically duringmint-tsdocs generate. There are currently no configuration options to disable or customize it.
Known Limitations
1. Entry Point Scope
_findApiItemByName() only searches the first entry point of each package. This means:
Won’t resolve:
- Types in nested namespaces
- Re-exported types from external packages
- Types in additional entry points
- Top-level interfaces, classes, type aliases
- Types in the same package as the referencing property
2. Inline Object Types
Properties within inline object type literals don’t have descriptions:3. Complex Type References
Advanced TypeScript features may not be fully resolved:- Conditional types
- Mapped types
- Template literal types
- Utility types (Partial, Pick, etc.)
Future Improvements
1. Enhanced Type Resolution
- Support for nested namespace members
- Cross-package type resolution
- Handling of re-exported types
2. Smarter Caching
- Replace
JSON.stringify()in API resolution cache - Implement TTL for cache entries
- Statistics for cache hit rates
3. Configuration Options
- Option to disable TypeInfo generation
- Control over recursion depth
- Custom type transformers
4. Error Handling
- Better diagnostics when type resolution fails
- Warnings for unresolved type references
- Validation of generated TypeInfo structure
Testing
TypeInfo generation is tested through:- Snapshot tests: Verify output structure remains consistent
- Integration tests: Run full generation pipeline on test projects
- Manual verification: Check generated files in actual documentation
Related Architecture
- Generation Layer - Overall documentation generation flow
- Caching Layer - Performance optimization details
- Utils Layer - ObjectTypeAnalyzer and other utilities

