Intro
This library extracts interface definitions from a TypeScript source file and parses it into a JSON-compatible JavaScript object.
Use it to turn this
;;;;;
into this
Address: city: 'string' 'number' country: 'string' Attendee: id: 'string' person: name: 'string' isUnderage: 'boolean' phoneNumbers: 'string' address: city: 'string' 'number' country: 'string' accompaniedBy: name: 'string' isUnderage: 'boolean' phoneNumbers: 'string' address: city: 'string' 'number' country: 'string' status: 'beginner' 'experienced' 'pro' accessLv: 1 2 3 Person: name: 'string' isUnderage: 'boolean' phoneNumbers: 'string' address: city: 'string' 'number' country: 'string'
Usage
The exported function extractInterfacesFromFile
takes a filepath argument:
; const result = ; console; /* Person: { name: 'string', isUnderage: 'boolean', phoneNumbers: ['string'], address: { city: ['string', 'number'], country: 'string', }, } */