mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix the semantic diagnostics caching in builder to handle conversion from relative to buildInfo to absolute path (#33168)
Fixes #33161
This commit is contained in:
parent
e2b94231c8
commit
5ea4257e6e
@ -1036,7 +1036,7 @@ namespace ts {
|
||||
compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath),
|
||||
referencedMap: getMapOfReferencedSet(program.referencedMap, toPath),
|
||||
exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath),
|
||||
semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && arrayToMap(program.semanticDiagnosticsPerFile, value => isString(value) ? value : value[0], value => isString(value) ? emptyArray : value[1]),
|
||||
semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && arrayToMap(program.semanticDiagnosticsPerFile, value => toPath(isString(value) ? value : value[0]), value => isString(value) ? emptyArray : value[1]),
|
||||
hasReusableDiagnostic: true
|
||||
};
|
||||
return {
|
||||
|
||||
@ -542,6 +542,49 @@ namespace ts.tscWatch {
|
||||
],
|
||||
expectedIncrementalErrors: file2Errors,
|
||||
});
|
||||
|
||||
it("verify that state is read correctly", () => {
|
||||
const system = createWatchedSystem([libFile, file1, fileModified, config], { currentDirectory: project });
|
||||
incrementalBuild("tsconfig.json", system);
|
||||
|
||||
const command = parseConfigFileWithSystem("tsconfig.json", {}, system, noop)!;
|
||||
const builderProgram = createIncrementalProgram({
|
||||
rootNames: command.fileNames,
|
||||
options: command.options,
|
||||
projectReferences: command.projectReferences,
|
||||
configFileParsingDiagnostics: getConfigFileParsingDiagnostics(command),
|
||||
host: createIncrementalCompilerHost(command.options, system)
|
||||
});
|
||||
|
||||
const state = builderProgram.getState();
|
||||
assert.equal(state.changedFilesSet!.size, 0, "changes");
|
||||
|
||||
assert.equal(state.fileInfos.size, 3, "FileInfo size");
|
||||
assert.deepEqual(state.fileInfos.get(libFile.path), libFileInfo);
|
||||
assert.deepEqual(state.fileInfos.get(file1.path), getFileInfo(file1.content));
|
||||
assert.deepEqual(state.fileInfos.get(file2.path), file2FileInfo);
|
||||
|
||||
assert.deepEqual(state.compilerOptions, {
|
||||
incremental: true,
|
||||
module: ModuleKind.AMD,
|
||||
configFilePath: config.path
|
||||
});
|
||||
|
||||
assert.equal(state.referencedMap!.size, 0);
|
||||
assert.equal(state.exportedModulesMap!.size, 0);
|
||||
|
||||
assert.equal(state.semanticDiagnosticsPerFile!.size, 3);
|
||||
assert.deepEqual(state.semanticDiagnosticsPerFile!.get(libFile.path), emptyArray);
|
||||
assert.deepEqual(state.semanticDiagnosticsPerFile!.get(file1.path), emptyArray);
|
||||
const { file: _, relatedInformation: __, ...rest } = file2ReuasableError[1][0];
|
||||
assert.deepEqual(state.semanticDiagnosticsPerFile!.get(file2.path), [{
|
||||
...rest,
|
||||
file: state.program!.getSourceFileByPath(file2.path as Path)!,
|
||||
relatedInformation: undefined,
|
||||
reportsUnnecessary: undefined,
|
||||
source: undefined
|
||||
}]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with --out", () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user