testSyntaxErrorSaysWhereAlone
A syntax error is said alone: where it is, as the checker says it, and the lines around it, the place marked; a long line around the place.
import { syntaxError } from "#codebase/tcmts/cli/main"; import assert from "node:assert/strict"; import { stripVTControlCharacters } from "node:util"; export const testSyntaxErrorSaysWhereAlone = () => { const d = { code: 1005, message: "',' expected.", formatted: "scratch.ts:2:5 - error TS1005: ',' expected.\n\n2 l2 bad\n ~\n", }; const said = stripVTControlCharacters(syntaxError(d, "l1\nl2 bad\nl3\nl4\nl5")).split("\n"); assert.deepEqual(said, [ "scratch.ts:2:5 - error TS1005: ',' expected.", "", " l1", "> l2 bad", " ^", " l3", " l4", ]); const long = stripVTControlCharacters( syntaxError( { ...d, formatted: "scratch.ts:1:201 - error" }, `${"x".repeat(200)}\`${"y".repeat(200)}`, ), ).split("\n"); assert.equal(long[2], `> …${"x".repeat(50)}\`${"y".repeat(49)}…`); assert.equal(long[3]!.indexOf("^"), long[2]!.indexOf("`")); }