@nodesecure/ts-source-parser
v1.0.0
Published
TypeScript parser for AST XRay analysis
Downloads
5
Readme
ts-source-parser
This package provide a TypeScript source parser for the @nodesecure/js-x-ray
project.
Getting Started
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
Usage example
import { TsSourceParser } from "@nodesecure/ts-source-parser";
const parser = new TsSourceParser();
const body = parser.parse("const x: number = 5;");
console.log(body);
Usage with js-x-ray
import { runASTAnalysis } 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 });