UNPKG

@ts-ast-parser/core

Version:

Reflects a simplified version of the TypeScript AST for generating documentation

29 lines 939 B
import { Project } from './project.js'; /** * Reflects a simplified version of the TypeScript Abstract * Syntax Tree from a TypeScript code snippet * * @param source - A string that represents the TypeScript source code * @param options - Options to configure the analyzer * @returns The reflected TypeScript AST */ export async function parseFromSource(source, options = {}) { if (!source) { return { project: null, errors: [{ messageText: 'Source code is empty.' }], }; } let system; if (options.system) { system = options.system; } else { const m = await import('./system/in-memory-system.js'); system = await m.InMemorySystem.create(); } const project = Project.fromSource(system, source, options); const errors = project.getDiagnostics().getAll(); return { project, errors }; } //# sourceMappingURL=parse-from-source.js.map