Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ts-source-parser package #218

Merged

Conversation

jean-michelet
Copy link
Contributor

This PR follows on from discussion #214, which proposes a new package in workspaces for parsing TypeScript files.

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

Copy link
Member

@PierreDemailly PierreDemailly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to add the workspace in the root package.json

"workspaces": [

Everything else lgtm

.github/workflows/ts-source-parser.yml Outdated Show resolved Hide resolved
.github/workflows/ts-source-parser.yml Outdated Show resolved Hide resolved
workspaces/ts-source-parser/package.json Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants