microsoft/TypeScript · error · Error

The baseline for ${relativeFileBase} in ${errors.length} fil

Error message

The baseline for ${relativeFileBase} in ${errors.length} files has changed:

What it means

Thrown by runMultifileBaseline (harnessIO.ts:1566) after iterating every file a generator yields. If any individual writeComparison threw (per-file baseline drift) or if any pre-existing reference file was no longer produced (`missing`), the harness aggregates up to five messages each and throws one combined error so a single test reports all drift.

Source

Thrown at src/harness/harnessIO.ts:1566

        if (missing.length) {
            for (const file of missing) {
                IO.writeFile(localPath(file + ".delete", opts && opts.Baselinefolder, opts && opts.Subfolder), "");
            }
        }

        if (errors.length || missing.length) {
            let errorMsg = "";
            if (errors.length) {
                errorMsg += `The baseline for ${relativeFileBase} in ${errors.length} files has changed:${"\n    " + errors.slice(0, 5).map(e => e.message).join("\n    ") + (errors.length > 5 ? "\n" + `    and ${errors.length - 5} more` : "")}`;
            }
            if (errors.length && missing.length) {
                errorMsg += "\n";
            }
            if (missing.length) {
                const writtenFilesArray = ts.arrayFrom(writtenFiles.keys());
                errorMsg += `Baseline missing ${missing.length} files:${"\n    " + missing.slice(0, 5).join("\n    ") + (missing.length > 5 ? "\n" + `    and ${missing.length - 5} more` : "") + "\n"}Written ${writtenFiles.size} files:${"\n    " + writtenFilesArray.slice(0, 5).join("\n    ") + (writtenFilesArray.length > 5 ? "\n" + `    and ${writtenFilesArray.length - 5} more` : "")}`;
            }
            throw new Error(errorMsg);
        }
    }
}

export function isDefaultLibraryFile(filePath: string): boolean {
    // We need to make sure that the filePath is prefixed with "lib." not just containing "lib." and end with ".d.ts"
    const fileName = ts.getBaseFileName(ts.normalizeSlashes(filePath));
    return ts.startsWith(fileName, "lib.") && ts.endsWith(fileName, ts.Extension.Dts);
}

export function isBuiltFile(filePath: string): boolean {
    return filePath.indexOf(libFolder) === 0 ||
        filePath.indexOf(vpath.addTrailingSeparator(vfs.builtFolder)) === 0;
}

export function getDefaultLibraryFile(filePath: string, io: IO): Compiler.TestFile {
    const libFile = userSpecifiedRoot + libFolder + ts.getBaseFileName(ts.normalizeSlashes(filePath));
    return { unitName: libFile, content: io.readFile(libFile)! };

View on GitHub (pinned to b465fdbfe1)

Solutions

  1. Read the aggregated message — it lists the per-file errors (up to 5) and the missing files (up to 5) so you can see the full scope.
  2. If the changes are intended, run `hereby baseline-accept` to regenerate every multifile reference and clear `.delete` markers.
  3. If a file is listed as missing, confirm the compiler should no longer emit it, then accept so the stale reference is removed.
  4. If a per-file change is unexpected, drill into that specific reference diff before accepting anything.

Example fix

# before
$ hereby test-compiler
Error: The baseline for foo in 3 files has changed:
    ...

# after — review then accept the whole multifile set
$ ls tests/baselines/local/foo/
$ hereby baseline-accept
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check each yielded file against its reference so the aggregate error never fires.
const expectedMap = readAllReferenceFiles(referenceDir);
const drift: string[] = [];
for (const [name, content] of generator()) {
  if (expectedMap.get(name) !== Utils.encodeString(content)) drift.push(name);
}
if (drift.length) console.warn('Multifile drift in:', drift.join(', '));

Try / catch

try {
  runMultifileBaseline(relativeFileBase, extension, generateContent, opts);
} catch (e) {
  if (/baseline for .* in \d+ files has changed|Baseline missing/.test(e.message)) {
    multifileDriftQueue.push(relativeFileBase); // batch-accept later
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: A multifile baseline generator yields N output files; one or more differ from their reference baselines, or reference files exist on disk that the generator no longer emits. Each per-file error is caught (harnessIO.ts:1528) and pushed into the `errors` array; missing references go into `missing`.

Common situations: Compiler change that alters some emitted files but not others; renaming output files so old references become 'missing'; reducing emit so fewer files are written; a refactor that changes only one of several declaration files.

Related errors


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