UNPKG

@nodesecure/js-x-ray

Version:
31 lines 837 B
// Import Third-party Dependencies import { parse } from "@typescript-eslint/typescript-estree"; import {} from "meriyah"; // CONSTANTS const kTypeScriptParsingOptions = { jsDocParsingMode: "none", jsx: true, loc: true, range: false }; export class TsSourceParser { static FileExtensions = new Set([ ".ts", ".mts", ".cts", ".tsx" ]); parse(source, options = {}) { const { body } = parse(source, { ...kTypeScriptParsingOptions, ...options }); /** * Not pretty but the types are not compatible and we know * that the body is compatible with ESTree.Statement[] * since the parser is designed to be compatible with ESTree. */ return body; } } //# sourceMappingURL=TsSourceParser.js.map