Skip to content

Latest commit

 

History

History

ts-source-parser

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ts-source-parser

version maintained OpenSSF Scorecard mit build

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 { 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 });