A utility for extracting API descriptions from TypeScript definitions using the TypeScript Compiler API. This tool analyzes TypeScript source code and generates structured metadata about exported functions, components, interfaces, types, and more.
- Extract API information from TypeScript source files
- React component analysis with prop types and documentation
- Type definitions including interfaces, enums, and type aliases
- JSDoc comments parsing and extraction
- Reference resolution for complex type relationships
- Selective parsing of specific files or entire projects
npm install typescript-api-extractoror with yarn:
yarn add typescript-api-extractoror with pnpm:
pnpm add typescript-api-extractorimport {
createProgram,
loadConfig,
parseFromProgram,
type ModuleNode,
} from 'typescript-api-extractor';
// Load TypeScript configuration
const config = loadConfig('./tsconfig.json');
const program = createProgram(config.fileNames, config.options);
// Parse all files in the project
for (const file of config.fileNames) {
try {
const moduleInfo: ModuleNode = parseFromProgram(file, program);
console.log(`Extracted API from ${file}:`, moduleInfo);
} catch (error) {
console.error(`Failed to parse ${file}:`, error);
}
}- Usage - parsing a project or a single file, filtering properties, limiting object expansion, and handling parser warnings.
- API reference - exported functions,
ParserOptions, and the parser warning types. - Output format - the extracted module model, type operator representation, and an annotated example.
- Architecture - how the parser layers, resolver pipeline, and model helpers fit together.
- Node.js:
^22.12.0 || ^24.0.0 || >=26.0.0
This project is licensed under the terms of the MIT license.
This project was started as a fork of typescript-to-proptypes created by Kristoffer K..