Absolute path to the TypeScript file to parse
Map of interface names to their parsed definitions
This function reads and parses a TypeScript file to extract all interface definitions. It handles complex nested structures, inheritance, and caches results for performance. The function is resilient to parsing errors and will log warnings for problematic files.
const interfaces = extractInterfacesFromFile('/src/types/user.ts');
console.log(interfaces.get('UserProfile'));
// Returns: { name: 'UserProfile', properties: [...], extends: undefined }
Extracts all TypeScript interface definitions from a source file