microsoft/TypeScript · error · Error

${fileName}(${line},${col}): ${message}

Error message

${fileName}(${line},${col}): ${message}

What it means

reportError is a generic formatting helper (not a single condition) that throws an Error with the form fileName(line,col): message. It is invoked from seven sites in fourslash test parsing: unparseable object markers, empty object markers, duplicate markers, range-end-without-start, unterminated ranges, and unterminated markers. The message text after the position prefix identifies which structural problem was found in the test source.

Source

Thrown at src/harness/fourslashImpl.ts:4857

        files,
        symlinks,
        ranges,
    };
}

function isConfig(file: FourSlashFile): boolean {
    return Harness.getConfigNameFromFileName(file.fileName) !== undefined;
}

const enum State {
    none,
    inSlashStarMarker,
    inObjectMarker,
}

function reportError(fileName: string, line: number, col: number, message: string): never {
    const errorMessage = fileName + "(" + line + "," + col + "): " + message;
    throw new Error(errorMessage);
}

function recordObjectMarker(fileName: string, location: LocationInformation, text: string, markerMap: Map<string, Marker>, markers: Marker[]): Marker | undefined {
    let markerValue;
    try {
        // Attempt to parse the marker value as JSON
        markerValue = JSON.parse("{ " + text + " }") as { name?: unknown; };
    }
    catch (e) {
        reportError(fileName, location.sourceLine, location.sourceColumn, "Unable to parse marker text " + e.message);
    }

    if (markerValue === undefined) {
        reportError(fileName, location.sourceLine, location.sourceColumn, "Object markers can not be empty");
    }

    const marker: Marker = {
        fileName,

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Use the line,column in the message to jump to the exact token in the test file.
  2. Match the trailing message to the condition: 'Unable to parse marker text' -> fix the JSON in the object marker; 'Object markers can not be empty' -> add content; 'Marker ... is duplicated' -> rename one; 'Found range end with no matching start' -> add an opening [|; 'Unterminated range' / 'Unterminated marker' -> add the matching close.
  3. Re-validate the file with a fourslash linter or by comparing against a known-good test.

Example fix

// before — unterminated range
// [|const x = 1;
// const y = 2;
// after
// [|const x = 1;|]
// const y = 2;
Defensive patterns

Strategy: validation

Validate before calling

// Validate marker/range balance before running the test
function validateMarkers(content: string) {
    const openRanges = (content.match(/\[\|/g) || []).length;
    const closeRanges = (content.match(/\|\]/g) || []).length;
    if (openRanges !== closeRanges) throw new Error(`Unbalanced ranges: ${openRanges} open vs ${closeRanges} close`);
    const openMarkers = (content.match(/\/\*</g) || []).length;
    const closeMarkers = (content.match(/\*>\//g) || []).length;
    if (openMarkers !== closeMarkers) throw new Error(`Unbalanced markers`);
}

Prevention

When it happens

Trigger: Any malformed fourslash marker/range syntax during parseFileContent: object marker text that fails JSON.parse, an empty object marker, two markers sharing the same name, a range close [| without a matching open, a [| ... range never closed, or a /*<...>*/ marker never closed.

Common situations: Hand-editing fourslash test files and breaking marker syntax — e.g. unbalanced [| |] pairs, malformed JSON inside object markers, or duplicate marker names across the file. The error pinpoints the line and column of the offending token.

Related errors


AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12). Data as JSON: /api/errors/5cffbb2597c63baf. Report an issue: GitHub.