@nodesecure/ts-source-parser
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

/@nodesecure/ts-source-parser/

    Package Sidebar

    Install

    npm i @nodesecure/ts-source-parser

    Weekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    4.6 kB

    Total Files

    4

    Last publish

    Collaborators

    • pierred
    • antoine-coulon
    • kawacrepe
    • fraxken
    • tonygo