ts-extractor
TypeScript icon, indicating that this package has built-in type declarations

3.1.5 • Public • Published

ts-extractor

NPM version Build Status Coverage Status dependencies Status devDependencies Status devDependencies Status

TypeScript AST extractor to useful JSON structure.

The purpose of this package is to extract AST into flat JSON structures.

Later on, it can be used for documentation generation tool, easier code analysis with without compiler, etc.

Usage example

import * as path from "path";
import * as process from "process";
import { Extractor, GetCompilerOptions } from "ts-extractor";
 
async function Main(): Promise<void> {
    // Absolute path to projectDirectory
    const projectDirectory = process.cwd();
    const pathToTsconfig = path.join(projectDirectory, "./tsconfig.json");
 
    const compilerOptions = await GetCompilerOptions(pathToTsconfig);
 
    const extractor = new Extractor({
        CompilerOptions: compilerOptions,
        ProjectDirectory: projectDirectory
    });
 
    const extractedOutput = extractor.Extract(["./src/index.ts", "./src/another-entry-file.ts"]);
    console.log(extractedOutput);
}
 
Main();

Package Sidebar

Install

npm i ts-extractor

Weekly Downloads

59

Version

3.1.5

License

MIT

Last publish

Collaborators

  • quatrodev
  • simplrjs-admin