microsoft/TypeScript · error · Error

Unknown marker "${markerName}" Available markers: ${this.get

Error message

Unknown marker "${markerName}" Available markers: ${this.getMarkerNames().map(m => '"' + m + '"').join(", ")}

What it means

Thrown by getMarkerByName when the requested marker name is not present in testData.markerPositions. The message lists all available marker names (quoted, comma-separated) to help the author pick a valid one. Markers are declared in fourslash content with /*<markerName>*/ or object-marker syntax.

Source

Thrown at src/harness/fourslashImpl.ts:4475

                availableNames.push(fn);
            }
        });
        return { file, availableNames };
    }

    private hasFile(name: string): boolean {
        return this.tryFindFileWorker(name).file !== undefined;
    }

    private getLineColStringAtPosition(position: number, file: FourSlashFile = this.activeFile) {
        const pos = this.languageServiceAdapterHost.positionToLineAndCharacter(file.fileName, position);
        return `line ${(pos.line + 1)}, col ${pos.character}`;
    }

    public getMarkerByName(markerName: string): Marker {
        const markerPos = this.testData.markerPositions.get(markerName);
        if (markerPos === undefined) {
            throw new Error(`Unknown marker "${markerName}" Available markers: ${this.getMarkerNames().map(m => '"' + m + '"').join(", ")}`);
        }
        else {
            return markerPos;
        }
    }

    public setCancelled(numberOfCalls: number): void {
        this.cancellationToken.setCancelled(numberOfCalls);
    }

    public resetCancelled(): void {
        this.cancellationToken.resetCancelled();
    }

    public getEditsForFileRename({ oldPath, newPath, newFileContents, preferences }: FourSlashInterface.GetEditsForFileRenameOptions): void {
        const test = (fileContents: { readonly [fileName: string]: string; }, description: string): void => {
            const changes = this.languageService.getEditsForFileRename(oldPath, newPath, this.formatCodeSettings, preferences);
            this.testNewFileContents(changes, fileContents, description);

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Compare the requested name against the available markers listed in the error message.
  2. Add the missing marker at the intended position using /*<myMarker>*/ in the test content.
  3. Fix the typo or use the correct existing marker name.

Example fix

// before — content has /*<start>*/ but test says
// goTo.marker("begin");
// after
goTo.marker("start");
Defensive patterns

Strategy: validation

Validate before calling

function assertMarkerExists(state: FourSlashTestState, name: string) {
    if (!state.getMarkerNames().includes(name)) {
        throw new Error(`Marker '${name}' missing. Known: ${state.getMarkerNames().join(", ")}`);
    }
}

Prevention

When it happens

Trigger: Calling goTo.marker("myMarker") / getMarkerByName("myMarker") in a fourslash test that has no marker with that name. getMarkerNames() reflects only markers defined via the fourslash marker syntax during parseFileContent.

Common situations: Typo in the marker name, marker was removed during an edit, or the marker syntax is malformed so it was never registered. Also happens when copying a test that referenced markers without copying the marker definitions.

Related errors


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