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
- 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.
- If the changes are intended, run `hereby baseline-accept` to regenerate every multifile reference and clear `.delete` markers.
- If a file is listed as missing, confirm the compiler should no longer emit it, then accept so the stale reference is removed.
- 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
- Accept multifile baselines as a unit to avoid partial drift.
- When renaming/removing emitted files, regenerate the whole reference directory.
- Review each per-file message in the aggregate error before accepting.
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
- verifyFileContent in file '${fileName}' failed:\n${showTextD
- Expected at least one js file to be emitted or at least one
- The baseline file ${relativeFileName} has changed. (Run "her
- New baseline created at ${IO.joinPath("tests", "baselines",
- The generated content was "undefined". Return "null" if no b
AI-assisted analysis of microsoft/TypeScript@b465fdbfe1 (2026-08-12).
Data as JSON: /api/errors/fa7ea631dd44ee61.
Report an issue: GitHub.