{"record":{"id":"fa7ea631dd44ee61","repo":"microsoft/TypeScript","slug":"the-baseline-for-relativefilebase-in-errors-l","errorCode":null,"errorMessage":"The baseline for ${relativeFileBase} in ${errors.length} files has changed:","messagePattern":"The baseline for (.+?) in (.+?) files has changed:","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/harness/harnessIO.ts","lineNumber":1566,"sourceCode":"        if (missing.length) {\r\n            for (const file of missing) {\r\n                IO.writeFile(localPath(file + \".delete\", opts && opts.Baselinefolder, opts && opts.Subfolder), \"\");\r\n            }\r\n        }\r\n\r\n        if (errors.length || missing.length) {\r\n            let errorMsg = \"\";\r\n            if (errors.length) {\r\n                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` : \"\")}`;\r\n            }\r\n            if (errors.length && missing.length) {\r\n                errorMsg += \"\\n\";\r\n            }\r\n            if (missing.length) {\r\n                const writtenFilesArray = ts.arrayFrom(writtenFiles.keys());\r\n                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` : \"\")}`;\r\n            }\r\n            throw new Error(errorMsg);\r\n        }\r\n    }\r\n}\r\n\r\nexport function isDefaultLibraryFile(filePath: string): boolean {\r\n    // We need to make sure that the filePath is prefixed with \"lib.\" not just containing \"lib.\" and end with \".d.ts\"\r\n    const fileName = ts.getBaseFileName(ts.normalizeSlashes(filePath));\r\n    return ts.startsWith(fileName, \"lib.\") && ts.endsWith(fileName, ts.Extension.Dts);\r\n}\r\n\r\nexport function isBuiltFile(filePath: string): boolean {\r\n    return filePath.indexOf(libFolder) === 0 ||\r\n        filePath.indexOf(vpath.addTrailingSeparator(vfs.builtFolder)) === 0;\r\n}\r\n\r\nexport function getDefaultLibraryFile(filePath: string, io: IO): Compiler.TestFile {\r\n    const libFile = userSpecifiedRoot + libFolder + ts.getBaseFileName(ts.normalizeSlashes(filePath));\r\n    return { unitName: libFile, content: io.readFile(libFile)! };\r","sourceCodeStart":1548,"sourceCodeEnd":1584,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/harness/harnessIO.ts#L1548-L1584","documentation":"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.","triggerScenarios":"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`.","commonSituations":"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.","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."],"exampleFix":"# before\n$ hereby test-compiler\nError: The baseline for foo in 3 files has changed:\n    ...\n\n# after — review then accept the whole multifile set\n$ ls tests/baselines/local/foo/\n$ hereby baseline-accept","handlingStrategy":"try-catch","validationCode":"// Pre-check each yielded file against its reference so the aggregate error never fires.\nconst expectedMap = readAllReferenceFiles(referenceDir);\nconst drift: string[] = [];\nfor (const [name, content] of generator()) {\n  if (expectedMap.get(name) !== Utils.encodeString(content)) drift.push(name);\n}\nif (drift.length) console.warn('Multifile drift in:', drift.join(', '));","typeGuard":null,"tryCatchPattern":"try {\n  runMultifileBaseline(relativeFileBase, extension, generateContent, opts);\n} catch (e) {\n  if (/baseline for .* in \\d+ files has changed|Baseline missing/.test(e.message)) {\n    multifileDriftQueue.push(relativeFileBase); // batch-accept later\n    return;\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["test-harness","baseline","multifile","aggregated"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}