mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Cache resolved project references and watch wild card directories from them to update them (#42929)
* Test for not watchiong referenced projects fileNames and invalidating it * Add watching wild card directories and caching parsed command line for projects so that its shared * Handle config file watching and commandline cache together * Watch extended files for commndline cache instead of project * Use extended config cache now that we are watching extended config files * Structure for getParsedCommandLine from the LS * Adding some more skeleton with todos * getParsedCommandLine on WatchCompilerHost * Tests for Watch, LS scenarios * Handle getParsedCommandLine so we are looking at all things for referenced * Cleanup and commenting * Test for transitive references with tsc-watch * Cache parsed command line even if host implements getParsedCommandLine * Cleanup * Cleanup * Some tests to verify exclude from referenced project doesnt trigger the update * Baseline when program is same * Test for incremental scenario * Tests for output from referenced project * Comments
This commit is contained in:
1 parent
a26acf4540
commit
a545ab1ac2
39 files changed
+4649
-586
No files matched your search
@@ -916,6 +916,7 @@ namespace ts {
|
||||
path => program.getSourceFileByPath(path)!.version, /*fileExists*/ returnFalse,
|
||||
/*hasInvalidatedResolution*/ returnFalse,
|
||||
/*hasChangedAutomaticTypeDirectiveNames*/ undefined,
|
||||
/*getParsedCommandLine*/ returnUndefined,
|
||||
/*projectReferences*/ undefined
|
||||
);
|
||||
}
|
||||
@@ -951,7 +952,7 @@ namespace ts {
|
||||
configFileName,
|
||||
system
|
||||
})).getCurrentProgram().getProgram();
|
||||
const { fileNames, options } = parseConfigFileWithSystem(configFileName, {}, /*watchOptionsToExtend*/ undefined, system, notImplemented)!; // TODO: GH#18217
|
||||
const { fileNames, options } = parseConfigFileWithSystem(configFileName, {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, notImplemented)!; // TODO: GH#18217
|
||||
verifyProgramIsUptoDate(program, fileNames, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,5 +138,135 @@ export function Component(x: Config): any;`
|
||||
verifyProgramUptoDate(/*useProjectVersion*/ false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("detects program upto date when new file is added to the referenced project", () => {
|
||||
function setup(useSourceOfProjectReferenceRedirect: (() => boolean) | undefined) {
|
||||
const config1: TestFSWithWatch.File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project1/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true
|
||||
},
|
||||
exclude: ["temp"]
|
||||
})
|
||||
};
|
||||
const class1: TestFSWithWatch.File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project1/class1.ts`,
|
||||
content: `class class1 {}`
|
||||
};
|
||||
const class1Dts: TestFSWithWatch.File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project1/class1.d.ts`,
|
||||
content: `declare class class1 {}`
|
||||
};
|
||||
const config2: TestFSWithWatch.File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project2/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true
|
||||
},
|
||||
references: [
|
||||
{ path: "../project1" }
|
||||
]
|
||||
})
|
||||
};
|
||||
const class2: TestFSWithWatch.File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project2/class2.ts`,
|
||||
content: `class class2 {}`
|
||||
};
|
||||
const system = projectSystem.createServerHost([config1, class1, class1Dts, config2, class2, projectSystem.libFile]);
|
||||
const result = getParsedCommandLineOfConfigFile(`${tscWatch.projectRoot}/projects/project2/tsconfig.json`, /*optionsToExtend*/ undefined, {
|
||||
useCaseSensitiveFileNames: true,
|
||||
fileExists: path => system.fileExists(path),
|
||||
readFile: path => system.readFile(path),
|
||||
getCurrentDirectory: () => system.getCurrentDirectory(),
|
||||
readDirectory: (path, extensions, excludes, includes, depth) => system.readDirectory(path, extensions, excludes, includes, depth),
|
||||
onUnRecoverableConfigFileDiagnostic: noop,
|
||||
})!;
|
||||
const host: LanguageServiceHost = {
|
||||
useCaseSensitiveFileNames: returnTrue,
|
||||
useSourceOfProjectReferenceRedirect,
|
||||
getCompilationSettings: () => result.options,
|
||||
fileExists: path => system.fileExists(path),
|
||||
getScriptFileNames: () => result.fileNames,
|
||||
getScriptVersion: path => {
|
||||
const text = system.readFile(path);
|
||||
return text !== undefined ? system.createHash(path) : "";
|
||||
},
|
||||
getScriptSnapshot: path => {
|
||||
const text = system.readFile(path);
|
||||
return text ? ScriptSnapshot.fromString(text) : undefined;
|
||||
},
|
||||
readDirectory: (path, extensions, excludes, includes, depth) => system.readDirectory(path, extensions, excludes, includes, depth),
|
||||
getCurrentDirectory: () => system.getCurrentDirectory(),
|
||||
getDefaultLibFileName: () => projectSystem.libFile.path,
|
||||
getProjectReferences: () => result.projectReferences,
|
||||
};
|
||||
const ls = ts.createLanguageService(host);
|
||||
return { system, ls, class1, class1Dts, class2 };
|
||||
}
|
||||
it("detects program upto date when new file is added to the referenced project", () => {
|
||||
const { ls, system, class1, class2 } = setup(returnTrue);
|
||||
assert.deepEqual(
|
||||
ls.getProgram()!.getSourceFiles().map(f => f.fileName),
|
||||
[projectSystem.libFile.path, class1.path, class2.path]
|
||||
);
|
||||
// Add new file to referenced project
|
||||
const class3 = `${tscWatch.projectRoot}/projects/project1/class3.ts`;
|
||||
system.writeFile(class3, `class class3 {}`);
|
||||
const program = ls.getProgram()!;
|
||||
assert.deepEqual(
|
||||
program.getSourceFiles().map(f => f.fileName),
|
||||
[projectSystem.libFile.path, class1.path, class3, class2.path]
|
||||
);
|
||||
// Add excluded file to referenced project
|
||||
system.ensureFileOrFolder({ path: `${tscWatch.projectRoot}/projects/project1/temp/file.d.ts`, content: `declare class file {}` });
|
||||
assert.strictEqual(ls.getProgram(), program);
|
||||
// Add output from new class to referenced project
|
||||
system.writeFile(`${tscWatch.projectRoot}/projects/project1/class3.d.ts`, `declare class class3 {}`);
|
||||
assert.strictEqual(ls.getProgram(), program);
|
||||
});
|
||||
|
||||
it("detects program upto date when new file is added to the referenced project without useSourceOfProjectReferenceRedirect", () => {
|
||||
const { ls, system, class1Dts, class2 } = setup(/*useSourceOfProjectReferenceRedirect*/ undefined);
|
||||
const program1 = ls.getProgram()!;
|
||||
assert.deepEqual(
|
||||
program1.getSourceFiles().map(f => f.fileName),
|
||||
[projectSystem.libFile.path, class1Dts.path, class2.path]
|
||||
);
|
||||
// Add new file to referenced project
|
||||
const class3 = `${tscWatch.projectRoot}/projects/project1/class3.ts`;
|
||||
system.writeFile(class3, `class class3 {}`);
|
||||
assert.notStrictEqual(ls.getProgram(), program1);
|
||||
assert.deepEqual(
|
||||
ls.getProgram()!.getSourceFiles().map(f => f.fileName),
|
||||
[projectSystem.libFile.path, class1Dts.path, class2.path]
|
||||
);
|
||||
// Add class3 output
|
||||
const class3Dts = `${tscWatch.projectRoot}/projects/project1/class3.d.ts`;
|
||||
system.writeFile(class3Dts, `declare class class3 {}`);
|
||||
const program2 = ls.getProgram()!;
|
||||
assert.deepEqual(
|
||||
program2.getSourceFiles().map(f => f.fileName),
|
||||
[projectSystem.libFile.path, class1Dts.path, class3Dts, class2.path]
|
||||
);
|
||||
// Add excluded file to referenced project
|
||||
system.ensureFileOrFolder({ path: `${tscWatch.projectRoot}/projects/project1/temp/file.d.ts`, content: `declare class file {}` });
|
||||
assert.strictEqual(ls.getProgram(), program2);
|
||||
// Delete output from new class to referenced project
|
||||
system.deleteFile(class3Dts);
|
||||
assert.deepEqual(
|
||||
ls.getProgram()!.getSourceFiles().map(f => f.fileName),
|
||||
[projectSystem.libFile.path, class1Dts.path, class2.path]
|
||||
);
|
||||
// Write output again
|
||||
system.writeFile(class3Dts, `declare class class3 {}`);
|
||||
assert.deepEqual(
|
||||
ls.getProgram()!.getSourceFiles().map(f => f.fileName),
|
||||
[projectSystem.libFile.path, class1Dts.path, class3Dts, class2.path]
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -333,7 +333,6 @@ interface Symbol {
|
||||
|
||||
interface VerifyIncrementalCorrectness {
|
||||
scenario: TscCompile["scenario"];
|
||||
subScenario: TscCompile["subScenario"];
|
||||
commandLineArgs: TscCompile["commandLineArgs"];
|
||||
modifyFs: TscCompile["modifyFs"];
|
||||
incrementalModifyFs: TscIncremental["modifyFs"];
|
||||
@@ -342,10 +341,10 @@ interface Symbol {
|
||||
newSys: TscCompileSystem;
|
||||
cleanBuildDiscrepancies: TscIncremental["cleanBuildDiscrepancies"];
|
||||
}
|
||||
function verifyIncrementalCorrectness(input: () => VerifyIncrementalCorrectness, index: number) {
|
||||
it(`Verify emit output file text is same when built clean for incremental scenario at:: ${index}`, () => {
|
||||
function verifyIncrementalCorrectness(input: () => VerifyIncrementalCorrectness, index: number, subScenario: TscCompile["subScenario"]) {
|
||||
it(`Verify emit output file text is same when built clean for incremental scenario at:: ${index} ${subScenario}`, () => {
|
||||
const {
|
||||
scenario, subScenario, commandLineArgs, cleanBuildDiscrepancies,
|
||||
scenario, commandLineArgs, cleanBuildDiscrepancies,
|
||||
modifyFs, incrementalModifyFs,
|
||||
tick, baseFs, newSys
|
||||
} = input();
|
||||
@@ -594,7 +593,6 @@ interface Symbol {
|
||||
verifyTscBaseline(() => newSys);
|
||||
verifyIncrementalCorrectness(() => ({
|
||||
scenario,
|
||||
subScenario: incrementalSubScenario || subScenario,
|
||||
baseFs,
|
||||
newSys,
|
||||
commandLineArgs: incrementalCommandLineArgs || commandLineArgs,
|
||||
@@ -602,7 +600,7 @@ interface Symbol {
|
||||
incrementalModifyFs,
|
||||
modifyFs,
|
||||
tick
|
||||
}), index);
|
||||
}), index, incrementalSubScenario || subScenario);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -692,7 +690,6 @@ interface Symbol {
|
||||
describe("incremental correctness", () => {
|
||||
incrementalScenarios.forEach(({ commandLineArgs: incrementalCommandLineArgs, subScenario, buildKind, cleanBuildDiscrepancies }, index) => verifyIncrementalCorrectness(() => ({
|
||||
scenario,
|
||||
subScenario: subScenario || buildKind,
|
||||
baseFs,
|
||||
newSys: incrementalSys[index],
|
||||
commandLineArgs: incrementalCommandLineArgs || commandLineArgs,
|
||||
@@ -704,7 +701,7 @@ interface Symbol {
|
||||
},
|
||||
modifyFs,
|
||||
tick
|
||||
}), index));
|
||||
}), index, subScenario || buildKind));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ts {
|
||||
;
|
||||
assert.deepEqual(
|
||||
getOutputFileNames(
|
||||
parseConfigFileWithSystem("/src/tsconfig.json", {}, {}, sys, noop)!,
|
||||
parseConfigFileWithSystem("/src/tsconfig.json", {}, /*extendedConfigCache*/ undefined, {}, sys, noop)!,
|
||||
"/src/src/index.ts",
|
||||
/*ignoreCase*/ false
|
||||
),
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace ts {
|
||||
sys.write(`exitCode:: ExitStatus.${ExitStatus[sys.exitCode as ExitStatus]}\n`);
|
||||
if (baselinePrograms) {
|
||||
const baseline: string[] = [];
|
||||
tscWatch.baselinePrograms(baseline, getPrograms, baselineDependencies);
|
||||
tscWatch.baselinePrograms(baseline, getPrograms, emptyArray, baselineDependencies);
|
||||
sys.write(baseline.join("\n"));
|
||||
}
|
||||
if (baselineReadFileCalls) {
|
||||
|
||||
@@ -333,5 +333,72 @@ declare global {
|
||||
commandLineArgs: ["--p", "src/project", "--strict"]
|
||||
});
|
||||
});
|
||||
|
||||
verifyTscSerializedIncrementalEdits({
|
||||
scenario: "incremental",
|
||||
subScenario: "when new file is added to the referenced project",
|
||||
commandLineArgs: ["-i", "-p", `src/projects/project2`],
|
||||
fs: () => loadProjectFromFiles({
|
||||
"/src/projects/project1/tsconfig.json": JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true
|
||||
},
|
||||
exclude: ["temp"]
|
||||
}),
|
||||
"/src/projects/project1/class1.ts": `class class1 {}`,
|
||||
"/src/projects/project1/class1.d.ts": `declare class class1 {}`,
|
||||
"/src/projects/project2/tsconfig.json": JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true
|
||||
},
|
||||
references: [
|
||||
{ path: "../project1" }
|
||||
]
|
||||
}),
|
||||
"/src/projects/project2/class2.ts": `class class2 {}`,
|
||||
}),
|
||||
incrementalScenarios: [
|
||||
{
|
||||
subScenario: "Add class3 to project1 and build it",
|
||||
buildKind: BuildKind.IncrementalDtsChange,
|
||||
modifyFs: fs => fs.writeFileSync("/src/projects/project1/class3.ts", `class class3 {}`, "utf-8"),
|
||||
cleanBuildDiscrepancies: () => new Map<string, CleanBuildDescrepancy>([
|
||||
// Ts buildinfo will not be updated in incremental build so it will have semantic diagnostics cached from previous build
|
||||
// But in clean build because of global diagnostics, semantic diagnostics are not queried so not cached in tsbuildinfo
|
||||
["/src/projects/project2/tsconfig.tsbuildinfo", CleanBuildDescrepancy.CleanFileTextDifferent]
|
||||
]),
|
||||
},
|
||||
{
|
||||
subScenario: "Add output of class3",
|
||||
buildKind: BuildKind.IncrementalDtsChange,
|
||||
modifyFs: fs => fs.writeFileSync("/src/projects/project1/class3.d.ts", `declare class class3 {}`, "utf-8"),
|
||||
},
|
||||
{
|
||||
subScenario: "Add excluded file to project1",
|
||||
buildKind: BuildKind.IncrementalDtsUnchanged,
|
||||
modifyFs: fs => {
|
||||
fs.mkdirSync("/src/projects/project1/temp");
|
||||
fs.writeFileSync("/src/projects/project1/temp/file.d.ts", `declare class file {}`, "utf-8");
|
||||
},
|
||||
},
|
||||
{
|
||||
subScenario: "Delete output for class3",
|
||||
buildKind: BuildKind.IncrementalDtsUnchanged,
|
||||
modifyFs: fs => fs.unlinkSync("/src/projects/project1/class3.d.ts"),
|
||||
cleanBuildDiscrepancies: () => new Map<string, CleanBuildDescrepancy>([
|
||||
// Ts buildinfo willbe updated but will retain lib file errors from previous build and not others because they are emitted because of change which results in clearing their semantic diagnostics cache
|
||||
// But in clean build because of global diagnostics, semantic diagnostics are not queried so not cached in tsbuildinfo
|
||||
["/src/projects/project2/tsconfig.tsbuildinfo", CleanBuildDescrepancy.CleanFileTextDifferent]
|
||||
]),
|
||||
},
|
||||
{
|
||||
subScenario: "Create output for class3",
|
||||
buildKind: BuildKind.IncrementalDtsUnchanged,
|
||||
modifyFs: fs => fs.writeFileSync("/src/projects/project1/class3.d.ts", `declare class class3 {}`, "utf-8"),
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -390,6 +390,7 @@ namespace ts.tscWatch {
|
||||
let programs = watchBaseline({
|
||||
baseline,
|
||||
getPrograms,
|
||||
oldPrograms: emptyArray,
|
||||
sys,
|
||||
oldSnap,
|
||||
baselineSourceMap,
|
||||
@@ -402,6 +403,7 @@ namespace ts.tscWatch {
|
||||
programs = watchBaseline({
|
||||
baseline,
|
||||
getPrograms,
|
||||
oldPrograms: programs,
|
||||
sys,
|
||||
oldSnap,
|
||||
baselineSourceMap,
|
||||
@@ -422,12 +424,13 @@ namespace ts.tscWatch {
|
||||
}
|
||||
|
||||
export interface WatchBaseline extends Baseline, TscWatchCheckOptions {
|
||||
oldPrograms: readonly (CommandLineProgram | undefined)[];
|
||||
getPrograms: () => readonly CommandLineProgram[];
|
||||
}
|
||||
export function watchBaseline({ baseline, getPrograms, sys, oldSnap, baselineSourceMap, baselineDependencies }: WatchBaseline) {
|
||||
export function watchBaseline({ baseline, getPrograms, oldPrograms, sys, oldSnap, baselineSourceMap, baselineDependencies }: WatchBaseline) {
|
||||
if (baselineSourceMap) generateSourceMapBaselineFiles(sys);
|
||||
sys.serializeOutput(baseline);
|
||||
const programs = baselinePrograms(baseline, getPrograms, baselineDependencies);
|
||||
const programs = baselinePrograms(baseline, getPrograms, oldPrograms, baselineDependencies);
|
||||
sys.serializeWatches(baseline);
|
||||
baseline.push(`exitCode:: ExitStatus.${ExitStatus[sys.exitCode as ExitStatus]}`, "");
|
||||
sys.diff(baseline, oldSnap);
|
||||
@@ -438,45 +441,56 @@ namespace ts.tscWatch {
|
||||
return programs;
|
||||
}
|
||||
|
||||
export function baselinePrograms(baseline: string[], getPrograms: () => readonly CommandLineProgram[], baselineDependencies: boolean | undefined) {
|
||||
export function baselinePrograms(baseline: string[], getPrograms: () => readonly CommandLineProgram[], oldPrograms: readonly (CommandLineProgram | undefined)[], baselineDependencies: boolean | undefined) {
|
||||
const programs = getPrograms();
|
||||
for (const program of programs) {
|
||||
baselineProgram(baseline, program, baselineDependencies);
|
||||
for (let i = 0; i < programs.length; i++) {
|
||||
baselineProgram(baseline, programs[i], oldPrograms[i], baselineDependencies);
|
||||
}
|
||||
return programs;
|
||||
}
|
||||
|
||||
function baselineProgram(baseline: string[], [program, builderProgram]: CommandLineProgram, baselineDependencies: boolean | undefined) {
|
||||
const options = program.getCompilerOptions();
|
||||
baseline.push(`Program root files: ${JSON.stringify(program.getRootFileNames())}`);
|
||||
baseline.push(`Program options: ${JSON.stringify(options)}`);
|
||||
baseline.push(`Program structureReused: ${(<any>ts).StructureIsReused[program.structureIsReused]}`);
|
||||
baseline.push("Program files::");
|
||||
for (const file of program.getSourceFiles()) {
|
||||
baseline.push(file.fileName);
|
||||
function baselineProgram(baseline: string[], [program, builderProgram]: CommandLineProgram, oldProgram: CommandLineProgram | undefined, baselineDependencies: boolean | undefined) {
|
||||
if (program !== oldProgram?.[0]) {
|
||||
const options = program.getCompilerOptions();
|
||||
baseline.push(`Program root files: ${JSON.stringify(program.getRootFileNames())}`);
|
||||
baseline.push(`Program options: ${JSON.stringify(options)}`);
|
||||
baseline.push(`Program structureReused: ${(<any>ts).StructureIsReused[program.structureIsReused]}`);
|
||||
baseline.push("Program files::");
|
||||
for (const file of program.getSourceFiles()) {
|
||||
baseline.push(file.fileName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
baseline.push(`Program: Same as old program`);
|
||||
}
|
||||
baseline.push("");
|
||||
|
||||
if (!builderProgram) return;
|
||||
const state = builderProgram.getState();
|
||||
if (state.semanticDiagnosticsPerFile?.size) {
|
||||
baseline.push("Semantic diagnostics in builder refreshed for::");
|
||||
for (const file of program.getSourceFiles()) {
|
||||
if (!state.semanticDiagnosticsFromOldState || !state.semanticDiagnosticsFromOldState.has(file.resolvedPath)) {
|
||||
baseline.push(file.fileName);
|
||||
if (builderProgram !== oldProgram?.[1]) {
|
||||
const state = builderProgram.getState();
|
||||
if (state.semanticDiagnosticsPerFile?.size) {
|
||||
baseline.push("Semantic diagnostics in builder refreshed for::");
|
||||
for (const file of program.getSourceFiles()) {
|
||||
if (!state.semanticDiagnosticsFromOldState || !state.semanticDiagnosticsFromOldState.has(file.resolvedPath)) {
|
||||
baseline.push(file.fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
baseline.push("No cached semantic diagnostics in the builder::");
|
||||
}
|
||||
baseline.push("");
|
||||
if (!baselineDependencies) return;
|
||||
baseline.push("Dependencies for::");
|
||||
for (const file of builderProgram.getSourceFiles()) {
|
||||
baseline.push(`${file.fileName}:`);
|
||||
for (const depenedency of builderProgram.getAllDependencies(file)) {
|
||||
baseline.push(` ${depenedency}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
baseline.push("No cached semantic diagnostics in the builder::");
|
||||
}
|
||||
baseline.push("");
|
||||
if (!baselineDependencies) return;
|
||||
baseline.push("Dependencies for::");
|
||||
for (const file of builderProgram.getSourceFiles()) {
|
||||
baseline.push(`${file.fileName}:`);
|
||||
for (const depenedency of builderProgram.getAllDependencies(file)) {
|
||||
baseline.push(` ${depenedency}`);
|
||||
}
|
||||
baseline.push(`BuilderProgram: Same as old builder program`);
|
||||
}
|
||||
baseline.push("");
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace ts.tscWatch {
|
||||
if (incremental) sys.exit = exitCode => sys.exitCode = exitCode;
|
||||
const argsToPass = [incremental ? "-i" : "-w", ...(optionsToExtend || emptyArray)];
|
||||
baseline.push(`${sys.getExecutingFilePath()} ${argsToPass.join(" ")}`);
|
||||
let oldPrograms: readonly CommandLineProgram[] = emptyArray;
|
||||
const { cb, getPrograms } = commandLineCallbacks(sys);
|
||||
build(oldSnap);
|
||||
|
||||
@@ -48,9 +49,10 @@ namespace ts.tscWatch {
|
||||
cb,
|
||||
argsToPass,
|
||||
);
|
||||
watchBaseline({
|
||||
oldPrograms = watchBaseline({
|
||||
baseline,
|
||||
getPrograms,
|
||||
oldPrograms,
|
||||
sys,
|
||||
oldSnap
|
||||
});
|
||||
@@ -134,7 +136,7 @@ namespace ts.tscWatch {
|
||||
it("verify that state is read correctly", () => {
|
||||
const system = createWatchedSystem([libFile, file1, fileModified, config], { currentDirectory: project });
|
||||
const reportDiagnostic = createDiagnosticReporter(system);
|
||||
const parsedConfig = parseConfigFileWithSystem("tsconfig.json", {}, /*watchOptionsToExtend*/ undefined, system, reportDiagnostic)!;
|
||||
const parsedConfig = parseConfigFileWithSystem("tsconfig.json", {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, reportDiagnostic)!;
|
||||
performIncrementalCompilation({
|
||||
rootNames: parsedConfig.fileNames,
|
||||
options: parsedConfig.options,
|
||||
@@ -144,7 +146,7 @@ namespace ts.tscWatch {
|
||||
system
|
||||
});
|
||||
|
||||
const command = parseConfigFileWithSystem("tsconfig.json", {}, /*watchOptionsToExtend*/ undefined, system, noop)!;
|
||||
const command = parseConfigFileWithSystem("tsconfig.json", {}, /*extendedConfigCache*/ undefined, /*watchOptionsToExtend*/ undefined, system, noop)!;
|
||||
const builderProgram = createIncrementalProgram({
|
||||
rootNames: command.fileNames,
|
||||
options: command.options,
|
||||
|
||||
@@ -1744,5 +1744,76 @@ import { x } from "../b";`),
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "when new file is added to the referenced project",
|
||||
commandLineArgs: ["-w", "-p", `${projectRoot}/projects/project2/tsconfig.json`, "--extendedDiagnostics"],
|
||||
sys: () => {
|
||||
const config1: File = {
|
||||
path: `${projectRoot}/projects/project1/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true
|
||||
},
|
||||
exclude: ["temp"]
|
||||
})
|
||||
};
|
||||
const class1: File = {
|
||||
path: `${projectRoot}/projects/project1/class1.ts`,
|
||||
content: `class class1 {}`
|
||||
};
|
||||
// Built file
|
||||
const class1Dt: File = {
|
||||
path: `${projectRoot}/projects/project1/class1.d.ts`,
|
||||
content: `declare class class1 {}`
|
||||
};
|
||||
const config2: File = {
|
||||
path: `${projectRoot}/projects/project2/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true
|
||||
},
|
||||
references: [
|
||||
{ path: "../project1" }
|
||||
]
|
||||
})
|
||||
};
|
||||
const class2: File = {
|
||||
path: `${projectRoot}/projects/project2/class2.ts`,
|
||||
content: `class class2 {}`
|
||||
};
|
||||
return createWatchedSystem([config1, class1, config2, class2, libFile, class1Dt]);
|
||||
},
|
||||
changes: [
|
||||
{
|
||||
caption: "Add class3 to project1",
|
||||
change: sys => sys.writeFile(`${projectRoot}/projects/project1/class3.ts`, `class class3 {}`),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun,
|
||||
},
|
||||
{
|
||||
caption: "Add output of class3",
|
||||
change: sys => sys.writeFile(`${projectRoot}/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun,
|
||||
},
|
||||
{
|
||||
caption: "Add excluded file to project1",
|
||||
change: sys => sys.ensureFileOrFolder({ path: `${projectRoot}/projects/project1/temp/file.d.ts`, content: `declare class file {}` }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
{
|
||||
caption: "Delete output of class3",
|
||||
change: sys => sys.deleteFile(`${projectRoot}/projects/project1/class3.d.ts`),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun,
|
||||
},
|
||||
{
|
||||
caption: "Add output of class3",
|
||||
change: sys => sys.writeFile(`${projectRoot}/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun,
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -295,5 +295,120 @@ X;`,
|
||||
],
|
||||
baselineDependencies: true,
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario: "projectsWithReferences",
|
||||
subScenario: "on transitive references in different folders with no files clause",
|
||||
sys: () => createSystemWithSolutionBuild(
|
||||
["c"],
|
||||
[
|
||||
libFile,
|
||||
{
|
||||
path: TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "a/tsconfig.json"),
|
||||
content: JSON.stringify({ compilerOptions: { composite: true } }),
|
||||
},
|
||||
{
|
||||
path: TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"),
|
||||
content: JSON.stringify({
|
||||
compilerOptions: { composite: true, baseUrl: "./", paths: { "@ref/*": ["../*"] } },
|
||||
references: [{ path: `../a` }]
|
||||
}),
|
||||
},
|
||||
{
|
||||
path: TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "c/tsconfig.json"),
|
||||
content: JSON.stringify({
|
||||
compilerOptions: { baseUrl: "./", paths: { "@ref/*": ["../refs/*"] } },
|
||||
references: [{ path: `../b` }]
|
||||
}),
|
||||
},
|
||||
{
|
||||
path: TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "a/index.ts"),
|
||||
content: `export class A {}`,
|
||||
},
|
||||
{
|
||||
path: TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "b/index.ts"),
|
||||
content: `import {A} from '@ref/a';
|
||||
export const b = new A();`,
|
||||
},
|
||||
{
|
||||
path: TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "c/index.ts"),
|
||||
content: `import {b} from '../b';
|
||||
import {X} from "@ref/a";
|
||||
b;
|
||||
X;`,
|
||||
},
|
||||
TestFSWithWatch.getTsBuildProjectFile("transitiveReferences", "refs/a.d.ts"),
|
||||
],
|
||||
{ currentDirectory: `${TestFSWithWatch.tsbuildProjectsLocation}/transitiveReferences` }
|
||||
),
|
||||
commandLineArgs: ["-w", "-p", "c"],
|
||||
changes: [
|
||||
{
|
||||
caption: "non local edit b ts, and build b",
|
||||
change: sys => {
|
||||
sys.appendFile(TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "b/index.ts"), `export function gfoo() { }`);
|
||||
const solutionBuilder = createSolutionBuilder(sys, ["b"]);
|
||||
solutionBuilder.build();
|
||||
},
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun
|
||||
},
|
||||
{
|
||||
caption: "edit on config file",
|
||||
change: sys => {
|
||||
sys.ensureFileOrFolder({
|
||||
path: TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "nrefs/a.d.ts"),
|
||||
content: sys.readFile(TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "refs/a.d.ts"))!
|
||||
});
|
||||
changeCompilerOpitonsPaths(sys, TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "c/tsconfig.json"), { "@ref/*": ["../nrefs/*"] });
|
||||
},
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun
|
||||
},
|
||||
{
|
||||
caption: "Revert config file edit",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "c/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun
|
||||
},
|
||||
{
|
||||
caption: "edit in referenced config file",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../nrefs/*"] }),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun
|
||||
},
|
||||
{
|
||||
caption: "Revert referenced config file edit",
|
||||
change: sys => changeCompilerOpitonsPaths(sys, TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"), { "@ref/*": ["../refs/*"] }),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun
|
||||
},
|
||||
{
|
||||
caption: "deleting referenced config file",
|
||||
change: sys => sys.deleteFile(TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2)
|
||||
},
|
||||
{
|
||||
caption: "Revert deleting referenced config file",
|
||||
change: sys => sys.writeFile(
|
||||
TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "b/tsconfig.json"),
|
||||
JSON.stringify({
|
||||
compilerOptions: { composite: true, baseUrl: "./", paths: { "@ref/*": ["../*"] } },
|
||||
references: [{ path: `../a` }]
|
||||
})
|
||||
),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2)
|
||||
},
|
||||
{
|
||||
caption: "deleting transitively referenced config file",
|
||||
change: sys => sys.deleteFile(TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "a/tsconfig.json")),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2)
|
||||
},
|
||||
{
|
||||
caption: "Revert deleting transitively referenced config file",
|
||||
change: sys => sys.writeFile(
|
||||
TestFSWithWatch.getTsBuildProjectFilePath("transitiveReferences", "a/tsconfig.json"),
|
||||
JSON.stringify({ compilerOptions: { composite: true } }),
|
||||
),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(2)
|
||||
},
|
||||
],
|
||||
baselineDependencies: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -243,4 +243,140 @@ namespace ts.tscWatch {
|
||||
verifyBuilder(config, sys, emitSys, createSemanticDiagnosticsBuilderProgram, createEmitAndSemanticDiagnosticsBuilderProgram, { noEmitOnError: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe("unittests:: tsc-watch:: watchAPI:: when getParsedCommandLine is implemented", () => {
|
||||
function setup(useSourceOfProjectReferenceRedirect?: () => boolean) {
|
||||
const config1: File = {
|
||||
path: `${projectRoot}/projects/project1/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true
|
||||
},
|
||||
exclude: ["temp"]
|
||||
})
|
||||
};
|
||||
const class1: File = {
|
||||
path: `${projectRoot}/projects/project1/class1.ts`,
|
||||
content: `class class1 {}`
|
||||
};
|
||||
const class1Dts: File = {
|
||||
path: `${projectRoot}/projects/project1/class1.d.ts`,
|
||||
content: `declare class class1 {}`
|
||||
};
|
||||
const config2: File = {
|
||||
path: `${projectRoot}/projects/project2/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true
|
||||
},
|
||||
references: [
|
||||
{ path: "../project1" }
|
||||
]
|
||||
})
|
||||
};
|
||||
const class2: File = {
|
||||
path: `${projectRoot}/projects/project2/class2.ts`,
|
||||
content: `class class2 {}`
|
||||
};
|
||||
const system = createWatchedSystem([config1, class1, class1Dts, config2, class2, libFile]);
|
||||
const baseline = createBaseline(system);
|
||||
const compilerHost = createWatchCompilerHostOfConfigFile({
|
||||
configFileName: config2.path,
|
||||
system,
|
||||
optionsToExtend: { extendedDiagnostics: true }
|
||||
});
|
||||
compilerHost.useSourceOfProjectReferenceRedirect = useSourceOfProjectReferenceRedirect;
|
||||
const calledGetParsedCommandLine = new Set<string>();
|
||||
compilerHost.getParsedCommandLine = fileName => {
|
||||
assert.isFalse(calledGetParsedCommandLine.has(fileName), `Already called on ${fileName}`);
|
||||
calledGetParsedCommandLine.add(fileName);
|
||||
return getParsedCommandLineOfConfigFile(fileName, /*optionsToExtend*/ undefined, {
|
||||
useCaseSensitiveFileNames: true,
|
||||
fileExists: path => system.fileExists(path),
|
||||
readFile: path => system.readFile(path),
|
||||
getCurrentDirectory: () => system.getCurrentDirectory(),
|
||||
readDirectory: (path, extensions, excludes, includes, depth) => system.readDirectory(path, extensions, excludes, includes, depth),
|
||||
onUnRecoverableConfigFileDiagnostic: noop,
|
||||
});
|
||||
};
|
||||
const watch = createWatchProgram(compilerHost);
|
||||
return { watch, baseline, config2, calledGetParsedCommandLine };
|
||||
}
|
||||
|
||||
it("when new file is added to the referenced project with host implementing getParsedCommandLine", () => {
|
||||
const { watch, baseline, config2, calledGetParsedCommandLine } = setup(returnTrue);
|
||||
runWatchBaseline({
|
||||
scenario: "watchApi",
|
||||
subScenario: "when new file is added to the referenced project with host implementing getParsedCommandLine",
|
||||
commandLineArgs: ["--w", "-p", config2.path, "--extendedDiagnostics"],
|
||||
...baseline,
|
||||
getPrograms: () => [[watch.getCurrentProgram().getProgram(), watch.getCurrentProgram()]],
|
||||
changes: [
|
||||
{
|
||||
caption: "Add class3 to project1",
|
||||
change: sys => {
|
||||
calledGetParsedCommandLine.clear();
|
||||
sys.writeFile(`${projectRoot}/projects/project1/class3.ts`, `class class3 {}`);
|
||||
},
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun,
|
||||
},
|
||||
{
|
||||
caption: "Add excluded file to project1",
|
||||
change: sys => sys.ensureFileOrFolder({ path: `${projectRoot}/projects/project1/temp/file.d.ts`, content: `declare class file {}` }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
{
|
||||
caption: "Add output of class3",
|
||||
change: sys => sys.writeFile(`${projectRoot}/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
],
|
||||
watchOrSolution: watch
|
||||
});
|
||||
});
|
||||
|
||||
it("when new file is added to the referenced project with host implementing getParsedCommandLine without implementing useSourceOfProjectReferenceRedirect", () => {
|
||||
const { watch, baseline, config2, calledGetParsedCommandLine } = setup();
|
||||
runWatchBaseline({
|
||||
scenario: "watchApi",
|
||||
subScenario: "when new file is added to the referenced project with host implementing getParsedCommandLine without implementing useSourceOfProjectReferenceRedirect",
|
||||
commandLineArgs: ["--w", "-p", config2.path, "--extendedDiagnostics"],
|
||||
...baseline,
|
||||
getPrograms: () => [[watch.getCurrentProgram().getProgram(), watch.getCurrentProgram()]],
|
||||
changes: [
|
||||
{
|
||||
caption: "Add class3 to project1",
|
||||
change: sys => {
|
||||
calledGetParsedCommandLine.clear();
|
||||
sys.writeFile(`${projectRoot}/projects/project1/class3.ts`, `class class3 {}`);
|
||||
},
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun,
|
||||
},
|
||||
{
|
||||
caption: "Add class3 output to project1",
|
||||
change: sys => sys.writeFile(`${projectRoot}/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun,
|
||||
},
|
||||
{
|
||||
caption: "Add excluded file to project1",
|
||||
change: sys => sys.ensureFileOrFolder({ path: `${projectRoot}/projects/project1/temp/file.d.ts`, content: `declare class file {}` }),
|
||||
timeouts: sys => sys.checkTimeoutQueueLength(0),
|
||||
},
|
||||
{
|
||||
caption: "Delete output of class3",
|
||||
change: sys => sys.deleteFile(`${projectRoot}/projects/project1/class3.d.ts`),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun,
|
||||
},
|
||||
{
|
||||
caption: "Add output of class3",
|
||||
change: sys => sys.writeFile(`${projectRoot}/projects/project1/class3.d.ts`, `declare class class3 {}`),
|
||||
timeouts: checkSingleTimeoutQueueLengthAndRun,
|
||||
},
|
||||
],
|
||||
watchOrSolution: watch
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1416,6 +1416,160 @@ bar;`
|
||||
});
|
||||
});
|
||||
|
||||
describe("when new file is added to the referenced project", () => {
|
||||
function setup(extendOptionsProject2?: CompilerOptions) {
|
||||
const config1: File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project1/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true
|
||||
},
|
||||
exclude: ["temp"]
|
||||
})
|
||||
};
|
||||
const class1: File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project1/class1.ts`,
|
||||
content: `class class1 {}`
|
||||
};
|
||||
const class1Dts: File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project1/class1.d.ts`,
|
||||
content: `declare class class1 {}`
|
||||
};
|
||||
const config2: File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project2/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: {
|
||||
module: "none",
|
||||
composite: true,
|
||||
...(extendOptionsProject2 || {})
|
||||
},
|
||||
references: [
|
||||
{ path: "../project1" }
|
||||
]
|
||||
})
|
||||
};
|
||||
const class2: File = {
|
||||
path: `${tscWatch.projectRoot}/projects/project2/class2.ts`,
|
||||
content: `class class2 {}`
|
||||
};
|
||||
const host = createServerHost([config1, class1, class1Dts, config2, class2, libFile]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession([class2], session);
|
||||
const service = session.getProjectService();
|
||||
return { host, session, service, class1, class1Dts, class2, config1, config2 };
|
||||
}
|
||||
|
||||
it("when referenced project is not open", () => {
|
||||
const { host, service, class1, class2, config2 } = setup();
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
const project2 = Debug.checkDefined(service.configuredProjects.get(config2.path));
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1.path, config2.path]);
|
||||
|
||||
// Add new class to referenced project
|
||||
const class3 = `${tscWatch.projectRoot}/projects/project1/class3.ts`;
|
||||
host.writeFile(class3, `class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1.path, config2.path, class3]);
|
||||
// Add excluded file to referenced project
|
||||
host.ensureFileOrFolder({ path: `${tscWatch.projectRoot}/projects/project1/temp/file.d.ts`, content: `declare class file {}` });
|
||||
host.checkTimeoutQueueLengthAndRun(0);
|
||||
// Add output from new class to referenced project
|
||||
const class3Dts = `${tscWatch.projectRoot}/projects/project1/class3.d.ts`;
|
||||
host.writeFile(class3Dts, `declare class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(0);
|
||||
});
|
||||
|
||||
it("when referenced project is open", () => {
|
||||
const { host, session, service, class1, class2, config1, config2 } = setup();
|
||||
openFilesForSession([class1], session);
|
||||
checkNumberOfProjects(service, { configuredProjects: 2 });
|
||||
const project1 = Debug.checkDefined(service.configuredProjects.get(config1.path));
|
||||
checkProjectActualFiles(project1, [libFile.path, class1.path, config1.path]);
|
||||
const project2 = Debug.checkDefined(service.configuredProjects.get(config2.path));
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1.path, config2.path]);
|
||||
|
||||
// Add new class to referenced project
|
||||
const class3 = `${tscWatch.projectRoot}/projects/project1/class3.ts`;
|
||||
host.writeFile(class3, `class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(3);
|
||||
checkProjectActualFiles(project1, [libFile.path, class1.path, config1.path, class3]);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1.path, config2.path, class3]);
|
||||
// Add excluded file to referenced project
|
||||
host.ensureFileOrFolder({ path: `${tscWatch.projectRoot}/projects/project1/temp/file.d.ts`, content: `declare class file {}` });
|
||||
host.checkTimeoutQueueLengthAndRun(0);
|
||||
// Add output from new class to referenced project
|
||||
const class3Dts = `${tscWatch.projectRoot}/projects/project1/class3.d.ts`;
|
||||
host.writeFile(class3Dts, `declare class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(0);
|
||||
});
|
||||
|
||||
it("when referenced project is not open with disableSourceOfProjectReferenceRedirect", () => {
|
||||
const { host, service, class1Dts, class2, config2 } = setup({ disableSourceOfProjectReferenceRedirect: true });
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
const project2 = Debug.checkDefined(service.configuredProjects.get(config2.path));
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path]);
|
||||
|
||||
// Add new class to referenced project
|
||||
const class3 = `${tscWatch.projectRoot}/projects/project1/class3.ts`;
|
||||
host.writeFile(class3, `class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path]);
|
||||
// Add output of new class to referenced project
|
||||
const class3Dts = `${tscWatch.projectRoot}/projects/project1/class3.d.ts`;
|
||||
host.writeFile(class3Dts, `declare class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path, class3Dts]);
|
||||
// Add excluded file to referenced project
|
||||
host.ensureFileOrFolder({ path: `${tscWatch.projectRoot}/projects/project1/temp/file.d.ts`, content: `declare class file {}` });
|
||||
host.checkTimeoutQueueLengthAndRun(0);
|
||||
// Delete output from new class to referenced project
|
||||
host.deleteFile(class3Dts);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path]);
|
||||
// Write back output of new class to referenced project
|
||||
host.writeFile(class3Dts, `declare class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path, class3Dts]);
|
||||
});
|
||||
|
||||
it("when referenced project is open with disableSourceOfProjectReferenceRedirect", () => {
|
||||
const { host, session, service, class1, class1Dts, class2, config1, config2 } = setup({ disableSourceOfProjectReferenceRedirect: true });
|
||||
openFilesForSession([class1], session);
|
||||
checkNumberOfProjects(service, { configuredProjects: 2 });
|
||||
const project1 = Debug.checkDefined(service.configuredProjects.get(config1.path));
|
||||
checkProjectActualFiles(project1, [libFile.path, class1.path, config1.path]);
|
||||
const project2 = Debug.checkDefined(service.configuredProjects.get(config2.path));
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path]);
|
||||
|
||||
// Add new class to referenced project
|
||||
const class3 = `${tscWatch.projectRoot}/projects/project1/class3.ts`;
|
||||
host.writeFile(class3, `class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(3);
|
||||
checkProjectActualFiles(project1, [libFile.path, class1.path, config1.path, class3]);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path]);
|
||||
// Add output of new class to referenced project
|
||||
const class3Dts = `${tscWatch.projectRoot}/projects/project1/class3.d.ts`;
|
||||
host.writeFile(class3Dts, `declare class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(project1, [libFile.path, class1.path, config1.path, class3]);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path, class3Dts]);
|
||||
// Add excluded file to referenced project
|
||||
host.ensureFileOrFolder({ path: `${tscWatch.projectRoot}/projects/project1/temp/file.d.ts`, content: `declare class file {}` });
|
||||
host.checkTimeoutQueueLengthAndRun(0);
|
||||
// Delete output from new class to referenced project
|
||||
host.deleteFile(class3Dts);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(project1, [libFile.path, class1.path, config1.path, class3]);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path]);
|
||||
// Write back output of new class to referenced project
|
||||
host.writeFile(class3Dts, `declare class class3 {}`);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(project1, [libFile.path, class1.path, config1.path, class3]);
|
||||
checkProjectActualFiles(project2, [class2.path, libFile.path, class1Dts.path, config2.path, class3Dts]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("auto import with referenced project", () => {
|
||||
function verifyAutoImport(built: boolean, disableSourceOfProjectReferenceRedirect?: boolean) {
|
||||
const solnConfig: File = {
|
||||
|
||||
@@ -892,7 +892,7 @@ fn5();
|
||||
}
|
||||
|
||||
function expectedScriptInfos() {
|
||||
return [dependencyTs.path, dependencyConfig.path, libFile.path, mainTs.path, randomFile.path];
|
||||
return [dependencyTs.path, libFile.path, mainTs.path, randomFile.path];
|
||||
}
|
||||
|
||||
function expectedWatchedFiles() {
|
||||
@@ -1303,7 +1303,7 @@ ${dependencyTs.content}`);
|
||||
}
|
||||
|
||||
function expectedScriptInfosWhenMapped() {
|
||||
return [mainTs.path, randomFile.path, dependencyTs.path, libFile.path, dtsPath, dtsMapLocation, dependencyConfig.path];
|
||||
return [mainTs.path, randomFile.path, dependencyTs.path, libFile.path, dtsPath, dtsMapLocation];
|
||||
}
|
||||
|
||||
function expectedWatchedFilesWhenMapped() {
|
||||
@@ -3298,7 +3298,7 @@ ${dependencyTs.content}`);
|
||||
}
|
||||
|
||||
function expectedScriptInfosAfterGotoDef() {
|
||||
return [dependencyTs.path, dependencyConfig.path, libFile.path, mainTs.path, randomFile.path];
|
||||
return [dependencyTs.path, libFile.path, mainTs.path, randomFile.path];
|
||||
}
|
||||
|
||||
function expectedWatchedFilesAfterGotoDef() {
|
||||
@@ -3933,7 +3933,7 @@ ${dependencyTs.content}`);
|
||||
}
|
||||
|
||||
function expectedScriptInfosWhenMapped() {
|
||||
return [mainTs.path, randomFile.path, dependencyTs.path, libFile.path, dtsPath, dtsMapLocation, dependencyConfig.path];
|
||||
return [mainTs.path, randomFile.path, dependencyTs.path, libFile.path, dtsPath, dtsMapLocation];
|
||||
}
|
||||
|
||||
function expectedWatchedFilesWhenMapped() {
|
||||
|
||||
@@ -15,7 +15,11 @@ namespace ts.projectSystem {
|
||||
|
||||
checkWatchedFilesDetailed(host, [coreConfig, coreIndex, coreAnotherModule, logicConfig, logicIndex, testsConfig, libFile].map(f => f.path.toLowerCase()), 1);
|
||||
checkWatchedDirectoriesDetailed(host, emptyArray, 1, /*recursive*/ false);
|
||||
checkWatchedDirectoriesDetailed(host, getTypeRootsFromLocation(TestFSWithWatch.getTsBuildProjectFilePath("sample1", "tests")), 1, /*recursive*/ true);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
TestFSWithWatch.getTsBuildProjectFilePath("sample1", "core"),
|
||||
TestFSWithWatch.getTsBuildProjectFilePath("sample1", "logic"),
|
||||
...getTypeRootsFromLocation(TestFSWithWatch.getTsBuildProjectFilePath("sample1", "tests"))
|
||||
], 1, /*recursive*/ true);
|
||||
|
||||
// local edit in ts file
|
||||
host.appendFile(logicIndex.path, `function foo() {}`);
|
||||
@@ -219,7 +223,7 @@ export class A {}`
|
||||
host.checkTimeoutQueueLengthAndRun(3); // Schedules failed lookup invalidation
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, refsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path], 1);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, bConfig.path, cConfig.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
@@ -229,7 +233,7 @@ export class A {}`
|
||||
...getTypeRootsFromLocation(`${tscWatch.projectRoot}/c`)
|
||||
], 1, /*recursive*/ true);
|
||||
// Script infos arent deleted till next file open
|
||||
checkOrphanScriptInfos(service, [aTs.path, aConfig.path]);
|
||||
checkOrphanScriptInfos(service, [aTs.path]);
|
||||
|
||||
// revert
|
||||
host.writeFile(bConfig.path, bConfig.content);
|
||||
@@ -283,5 +287,242 @@ export class A {}`
|
||||
checkOrphanScriptInfos(service, emptyArray);
|
||||
});
|
||||
});
|
||||
|
||||
describe("on transitive references in different folders without files", () => {
|
||||
function createService() {
|
||||
const aConfig: File = {
|
||||
path: `${tscWatch.projectRoot}/a/tsconfig.json`,
|
||||
content: JSON.stringify({ compilerOptions: { composite: true } }),
|
||||
};
|
||||
const bConfig: File = {
|
||||
path: `${tscWatch.projectRoot}/b/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: { composite: true, baseUrl: "./", paths: { "@ref/*": ["../*"] } },
|
||||
references: [{ path: `../a` }]
|
||||
}),
|
||||
};
|
||||
const cConfig: File = {
|
||||
path: `${tscWatch.projectRoot}/c/tsconfig.json`,
|
||||
content: JSON.stringify({
|
||||
compilerOptions: { baseUrl: "./", paths: { "@ref/*": ["../refs/*"] } },
|
||||
references: [{ path: `../b` }]
|
||||
}),
|
||||
};
|
||||
const aTs: File = {
|
||||
path: `${tscWatch.projectRoot}/a/index.ts`,
|
||||
content: `export class A {}`,
|
||||
};
|
||||
const bTs: File = {
|
||||
path: `${tscWatch.projectRoot}/b/index.ts`,
|
||||
content: `import {A} from '@ref/a';
|
||||
export const b = new A();`,
|
||||
};
|
||||
const cTs: File = {
|
||||
path: `${tscWatch.projectRoot}/c/index.ts`,
|
||||
content: `import {b} from '../b';
|
||||
import {X} from "@ref/a";
|
||||
b;
|
||||
X;`,
|
||||
};
|
||||
const refsTs: File = {
|
||||
path: `${tscWatch.projectRoot}/refs/a.d.ts`,
|
||||
content: `export class X {}
|
||||
export class A {}`
|
||||
};
|
||||
const host = createServerHost([libFile, aConfig, bConfig, cConfig, aTs, bTs, cTs, refsTs]);
|
||||
const service = createProjectService(host);
|
||||
service.openClientFile(cTs.path);
|
||||
return { host, service, aConfig, bConfig, cConfig, aTs, bTs, cTs, refsTs };
|
||||
}
|
||||
|
||||
it("non local edit", () => {
|
||||
const { host, service, aConfig, bConfig, cConfig, aTs, bTs, cTs, refsTs } = createService();
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, aTs.path, refsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
const expectedWatchedDirectoriesDetailed = arrayToMap([
|
||||
`${tscWatch.projectRoot}/c`, // Wild card directory
|
||||
`${tscWatch.projectRoot}/refs`, // Failed lookup since refs/a.ts does not exist
|
||||
...getTypeRootsFromLocation(`${tscWatch.projectRoot}/c`)
|
||||
], identity, () => 1);
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/a`, 2); // Failed to package json and wild card directory
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/b`, 2); // Failed to package json and wild card directory
|
||||
checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesDetailed, /*recursive*/ true);
|
||||
checkOrphanScriptInfos(service, emptyArray);
|
||||
|
||||
// non local edit
|
||||
host.appendFile(bTs.path, `export function gFoo() { }`);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, aTs.path, refsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesDetailed, /*recursive*/ true);
|
||||
checkOrphanScriptInfos(service, emptyArray);
|
||||
});
|
||||
|
||||
it("edit on config file", () => {
|
||||
const { host, service, aConfig, bConfig, cConfig, aTs, bTs, cTs, refsTs } = createService();
|
||||
const nRefsTs: File = {
|
||||
path: `${tscWatch.projectRoot}/nrefs/a.d.ts`,
|
||||
content: refsTs.content
|
||||
};
|
||||
const cTsConfigJson = JSON.parse(cConfig.content);
|
||||
host.ensureFileOrFolder(nRefsTs);
|
||||
cTsConfigJson.compilerOptions.paths = { "@ref/*": ["../nrefs/*"] };
|
||||
host.writeFile(cConfig.path, JSON.stringify(cTsConfigJson));
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, aTs.path, nRefsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path, nRefsTs.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
const expectedWatchedDirectoriesDetailed = arrayToMap([
|
||||
`${tscWatch.projectRoot}/c`, // Wild card directory
|
||||
`${tscWatch.projectRoot}/nrefs`, // Failed lookup since nrefs/a.ts does not exist
|
||||
...getTypeRootsFromLocation(`${tscWatch.projectRoot}/c`)
|
||||
], identity, () => 1);
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/a`, 2); // Failed to package json and wild card directory
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/b`, 2); // Failed to package json and wild card directory
|
||||
checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesDetailed, /*recursive*/ true);
|
||||
// Script infos arent deleted till next file open
|
||||
checkOrphanScriptInfos(service, [refsTs.path]);
|
||||
|
||||
// revert the edit on config file
|
||||
host.writeFile(cConfig.path, cConfig.content);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, aTs.path, refsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path, nRefsTs.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
expectedWatchedDirectoriesDetailed.delete(`${tscWatch.projectRoot}/nrefs`);
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/refs`, 1); // Failed lookup since refs/a.ts does not exist
|
||||
checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesDetailed, /*recursive*/ true);
|
||||
// Script infos arent deleted till next file open
|
||||
checkOrphanScriptInfos(service, [nRefsTs.path]);
|
||||
});
|
||||
|
||||
it("edit in referenced config file", () => {
|
||||
const { host, service, aConfig, bConfig, cConfig, aTs, bTs, cTs, refsTs } = createService();
|
||||
const nRefsTs: File = {
|
||||
path: `${tscWatch.projectRoot}/nrefs/a.d.ts`,
|
||||
content: refsTs.content
|
||||
};
|
||||
const bTsConfigJson = JSON.parse(bConfig.content);
|
||||
host.ensureFileOrFolder(nRefsTs);
|
||||
bTsConfigJson.compilerOptions.paths = { "@ref/*": ["../nrefs/*"] };
|
||||
host.writeFile(bConfig.path, JSON.stringify(bTsConfigJson));
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, refsTs.path, nRefsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path, nRefsTs.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
const expectedWatchedDirectoriesDetailed = arrayToMap([
|
||||
`${tscWatch.projectRoot}/a`, // Wild card directory
|
||||
`${tscWatch.projectRoot}/c`, // Wild card directory
|
||||
`${tscWatch.projectRoot}/refs`, // Failed lookup since refs/a.ts does not exist
|
||||
`${tscWatch.projectRoot}/nrefs`, // Failed lookup since nrefs/a.ts does not exist
|
||||
...getTypeRootsFromLocation(`${tscWatch.projectRoot}/c`)
|
||||
], identity, () => 1);
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/b`, 2); // Failed to package json and wild card directory
|
||||
checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesDetailed, /*recursive*/ true);
|
||||
// Script infos arent deleted till next file open
|
||||
checkOrphanScriptInfos(service, [aTs.path]);
|
||||
|
||||
// revert the edit on config file
|
||||
host.writeFile(bConfig.path, bConfig.content);
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, aTs.path, refsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path, nRefsTs.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
expectedWatchedDirectoriesDetailed.delete(`${tscWatch.projectRoot}/nrefs`);
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/a`, 2); // Failed to package json and wild card directory
|
||||
checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesDetailed, /*recursive*/ true);
|
||||
// Script infos arent deleted till next file open
|
||||
checkOrphanScriptInfos(service, [nRefsTs.path]);
|
||||
});
|
||||
|
||||
it("deleting referenced config file", () => {
|
||||
const { host, service, aConfig, bConfig, cConfig, aTs, bTs, cTs, refsTs } = createService();
|
||||
host.deleteFile(bConfig.path);
|
||||
host.checkTimeoutQueueLengthAndRun(3); // Schedules failed lookup invalidation
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, refsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, bConfig.path, cConfig.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
`${tscWatch.projectRoot}/c`, // Wild card directory
|
||||
`${tscWatch.projectRoot}/b`, // Failed to package json
|
||||
`${tscWatch.projectRoot}/refs`, // Failed lookup since refs/a.ts does not exist
|
||||
...getTypeRootsFromLocation(`${tscWatch.projectRoot}/c`)
|
||||
], 1, /*recursive*/ true);
|
||||
// Script infos arent deleted till next file open
|
||||
checkOrphanScriptInfos(service, [aTs.path]);
|
||||
|
||||
// revert
|
||||
host.writeFile(bConfig.path, bConfig.content);
|
||||
host.checkTimeoutQueueLengthAndRun(3); // Schedules failed lookup invalidation
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, aTs.path, refsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
const expectedWatchedDirectoriesDetailed = arrayToMap([
|
||||
`${tscWatch.projectRoot}/c`, // Wild card directory
|
||||
`${tscWatch.projectRoot}/refs`, // Failed lookup since refs/a.ts does not exist
|
||||
...getTypeRootsFromLocation(`${tscWatch.projectRoot}/c`)
|
||||
], identity, () => 1);
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/a`, 2); // Failed to package json and wild card directory
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/b`, 2); // Failed to package json and wild card directory
|
||||
checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesDetailed, /*recursive*/ true);
|
||||
checkOrphanScriptInfos(service, emptyArray);
|
||||
});
|
||||
|
||||
it("deleting transitively referenced config file", () => {
|
||||
const { host, service, aConfig, bConfig, cConfig, aTs, bTs, cTs, refsTs } = createService();
|
||||
host.deleteFile(aConfig.path);
|
||||
host.checkTimeoutQueueLengthAndRun(3); // Schedules failed lookup invalidation
|
||||
checkNumberOfProjects(service, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, aTs.path, refsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
const expectedWatchedDirectoriesDetailed = arrayToMap([
|
||||
`${tscWatch.projectRoot}/c`, // Wild card directory
|
||||
`${tscWatch.projectRoot}/a`, // Failed to package json
|
||||
`${tscWatch.projectRoot}/refs`, // Failed lookup since refs/a.ts does not exist
|
||||
...getTypeRootsFromLocation(`${tscWatch.projectRoot}/c`)
|
||||
], identity, () => 1);
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/b`, 2); // Failed to package json and wild card directory
|
||||
checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesDetailed, /*recursive*/ true);
|
||||
checkOrphanScriptInfos(service, emptyArray);
|
||||
|
||||
// revert
|
||||
host.writeFile(aConfig.path, aConfig.content);
|
||||
host.checkTimeoutQueueLengthAndRun(3); // Schedules failed lookup invalidation
|
||||
checkProjectActualFiles(service.configuredProjects.get(cConfig.path)!, [libFile.path, cTs.path, cConfig.path, bTs.path, aTs.path, refsTs.path]);
|
||||
checkWatchedFilesDetailed(host, [libFile.path, aTs.path, bTs.path, refsTs.path, aConfig.path, bConfig.path, cConfig.path], 1);
|
||||
checkWatchedDirectoriesDetailed(host, [
|
||||
tscWatch.projectRoot // watches for directories created for resolution of b
|
||||
], 1, /*recursive*/ false);
|
||||
expectedWatchedDirectoriesDetailed.set(`${tscWatch.projectRoot}/a`, 2); // Failed to package json and wild card directory
|
||||
checkWatchedDirectoriesDetailed(host, expectedWatchedDirectoriesDetailed, /*recursive*/ true);
|
||||
checkOrphanScriptInfos(service, emptyArray);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user