microsoft/TypeScript · error · Error
verifyCurrentLineContent\n
Error message
verifyCurrentLineContent\n
What it means
Assertion failure in the four-phase test harness (`src/harness/fourslashImpl.ts`). `verifyCurrentLineContent(text)` recomputes the line under the caret and compares it to `text`; on mismatch it throws `Error("verifyCurrentLineContent\n" + expected-vs-actual). This is a test-authoring assertion, not production code.
Source
Thrown at src/harness/fourslashImpl.ts:3038
const actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition, indentStyle, baseIndentSize);
const lineCol = this.getLineColStringAtPosition(this.currentCaretPosition);
if (actual !== numberOfSpaces) {
this.raiseError(`verifyIndentationAtCurrentPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);
}
}
public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number, indentStyle: ts.IndentStyle = ts.IndentStyle.Smart, baseIndentSize = 0): void {
const actual = this.getIndentation(fileName, position, indentStyle, baseIndentSize);
const lineCol = this.getLineColStringAtPosition(position);
if (actual !== numberOfSpaces) {
this.raiseError(`verifyIndentationAtPosition failed at ${lineCol} - expected: ${numberOfSpaces}, actual: ${actual}`);
}
}
public verifyCurrentLineContent(text: string): void {
const actual = this.getCurrentLineContent();
if (actual !== text) {
throw new Error("verifyCurrentLineContent\n" + displayExpectedAndActualString(text, actual, /*quoted*/ true));
}
}
public verifyCurrentFileContent(text: string): void {
this.verifyFileContent(this.activeFile.fileName, text);
}
private verifyFileContent(fileName: string, text: string) {
const actual = this.getFileContent(fileName);
if (actual !== text) {
throw new Error(`verifyFileContent in file '${fileName}' failed:\n${showTextDiff(text, actual)}`);
}
}
public verifyFormatDocumentChangesNothing(): void {
const { fileName } = this.activeFile;
const before = this.getFileContent(fileName);
this.formatDocument();
View on GitHub (pinned to b465fdbfe1)
Solutions
- Copy the actual line from the failure diff into the expected `text`.
- Re-check marker positions — the harness uses the caret to find the line.
- Account for indentation: the expected string must include leading whitespace.
- If the new behavior is correct, update the test; if not, fix the feature.
Example fix
// before
fourshaft.verifyCurrentLineContent("const x = 1;"); // actual has different indent/text
// after
fourshaft.verifyCurrentLineContent(" const x = 1;"); // copied from actual Defensive patterns
Strategy: validation
Prevention
- When a Fourslash assertion fails, paste the harness's reported `actual` rather than guessing.
- Keep expected strings aligned with the indentation style the formatter emits.
- Re-run only the affected Fourslash test for fast feedback.
When it happens
Trigger: Writing a Fourslash test where the marker positions or expected text don't match what the language service produced after an edit/completion. The harness finds the current line from the caret marker, so wrong marker placement also triggers it.
Common situations: Updating Fourslash baselines after a formatting/indentation behavior change; off-by-one marker placement; expected string that doesn't include leading indentation; behavior change in completion/format that wasn't reflected in the test.
Related errors
- verifyFileContent in file '${fileName}' failed:\n${showTextD
- verifyTextAtCaretIs\n
- You need to change the source code of fourslash test to use
- Exactly one refactor range is allowed per test.
- File index (${index}) in openFile was out of range. There ar
AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12).
Data as JSON: /api/errors/bb37583c6dd86bb3.
Report an issue: GitHub.