This package provide a TypeScript source parser for the @nodesecure/js-x-ray
project.
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
$ npm i @nodesecure/ts-source-parser
# or
$ yarn add @nodesecure/ts-source-parser
import { TsSourceParser } from "@nodesecure/ts-source-parser";
const parser = new TsSourceParser();
const body = parser.parse("const x: number = 5;");
console.log(body);
import { AstAnalyser } from "@nodesecure/js-x-ray";
import { readFileSync } from "node:fs";
const { warnings, dependencies } = runASTAnalysis(
readFileSync("./file.ts", "utf-8"),
{ customParser: new TsSourceParser() }
);
console.log(dependencies);
console.dir(warnings, { depth: null });