firstSyntaxError
The first syntax error in a file's analysis, if its code doesn't parse: one the parser reports, not one of the checker's that TypeScript numbers alike (1000–1999: an enum, where only erasable syntax is allowed, say).
import type { Analysis } from "#codebase/tcmts/core/analyze"; import type { Diagnostic } from "#codebase/tcmts/core/program"; export function firstSyntaxError(a: Analysis, file: string): Diagnostic | undefined { const sf = a.program.getSourceFile(file); if (!sf) return undefined; const parsed = new Set( a.program.getSyntacticDiagnostics(sf.fileName).map((d) => `${d.code} ${d.text}`), ); return parsed.size ? a.diagnostics.find((d) => parsed.has(`${d.code} ${d.message}`)) : undefined; }