Skip to content

Use .tsbuildinfo to build with tsc and tsc --w when not using build mode #30232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 9, 2019
Prev Previous commit
Next Next commit
Fix tests after rebase
  • Loading branch information
sheetalkamat committed Mar 9, 2019
commit 0b202b20954ca91a71c1723ef8ead36460c0e798
3 changes: 1 addition & 2 deletions src/compiler/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ namespace ts {

export function readBuilderProgram(compilerOptions: CompilerOptions, readFile: (path: string) => string | undefined) {
if (compilerOptions.out || compilerOptions.outFile) return undefined;
if (!isIncrementalCompilation(compilerOptions)) return undefined;
const buildInfoPath = getOutputPathForBuildInfo(compilerOptions);
if (!buildInfoPath) return undefined;
const content = readFile(buildInfoPath);
Expand Down Expand Up @@ -658,7 +657,7 @@ namespace ts {
((typeDirectiveNames, containingFile, redirectedReference) => resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference));
const userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;

readBuilderProgram(compilerOptions, path => compilerHost.readFile(path));
builderProgram = readBuilderProgram(compilerOptions, path => compilerHost.readFile(path)) as any as T;
synchronizeProgram();

// Update the wild card directory watch
Expand Down
16 changes: 2 additions & 14 deletions src/testRunner/unittests/tsbuild/outFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,7 @@ namespace ts {
// outputs
...outputFiles[project.first],
...outputFiles[project.second],

// build info
outputFiles[project.third][ext.buildinfo],
],
// These are first not present and later read new contents to generate third output
outputFiles[project.first][ext.buildinfo],
outputFiles[project.second][ext.buildinfo]
]
);

let dtsChangedExpectedDiagnostics: ReadonlyArray<fakes.ExpectedDiagnostic> = [
Expand All @@ -131,12 +125,8 @@ namespace ts {
...outputFiles[project.first],
...outputFiles[project.second],
outputFiles[project.third][ext.dts],

// build info
outputFiles[project.third][ext.buildinfo],
],
outputFiles[project.first][ext.dts], // dts changes so once read old content, and once new (to emit third)
outputFiles[project.first][ext.buildinfo], // since first build info changes
);

let dtsChangedExpectedDiagnosticsDependOrdered: ReadonlyArray<fakes.ExpectedDiagnostic> = [
Expand Down Expand Up @@ -173,8 +163,7 @@ namespace ts {
...outputFiles[project.first],
...outputFiles[project.second],
...outputFiles[project.third],
],
outputFiles[project.first][ext.buildinfo], // since first build info changes
]
);

let dtsUnchangedExpectedDiagnosticsDependOrdered: ReadonlyArray<fakes.ExpectedDiagnostic> = [
Expand Down Expand Up @@ -227,7 +216,6 @@ namespace ts {
value.set(path, 1);
}
value.set(outputFiles[project.second][ext.dts], 2); // dts changes so once read old content, and once new (to emit third)
value.set(outputFiles[project.second][ext.buildinfo], 2); // since first build info changes
return value;
}

Expand Down
32 changes: 21 additions & 11 deletions src/testRunner/unittests/tscWatch/incremental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace ts.tscWatch {
}

function checkFileEmit(actual: Map<string>, expected: ReadonlyArray<File>) {
assert.equal(actual.size, expected.length, `Actual: ${JSON.stringify(arrayFrom(actual.entries()))}\nExpected: ${JSON.stringify(expected)}`);
assert.equal(actual.size, expected.length, `Actual: ${JSON.stringify(arrayFrom(actual.entries()), /*replacer*/ undefined, " ")}\nExpected: ${JSON.stringify(expected, /*replacer*/ undefined, " ")}`);
expected.forEach(file => assert.equal(actual.get(file.path), file.content, `Emit for ${file.path}`));
}

Expand Down Expand Up @@ -93,7 +93,8 @@ namespace ts.tscWatch {
referencedMap: {},
exportedModulesMap: {},
semanticDiagnosticsPerFile: [libFile.path, file1.path, file2.path]
}
},
version
})
}
],
Expand All @@ -115,7 +116,8 @@ namespace ts.tscWatch {
referencedMap: {},
exportedModulesMap: {},
semanticDiagnosticsPerFile: [libFile.path, file1.path, file2.path]
}
},
version
})
}
],
Expand Down Expand Up @@ -170,7 +172,8 @@ namespace ts.tscWatch {
file1.path,
file2ReuasableError
]
}
},
version
})
}
],
Expand All @@ -196,7 +199,8 @@ namespace ts.tscWatch {
file1.path,
file2ReuasableError
]
}
},
version
})
}
],
Expand Down Expand Up @@ -228,7 +232,8 @@ namespace ts.tscWatch {
{ pos: 0, end: outFile.content.length, kind: BundleFileSectionKind.Text }
]
},
}
},
version
})
}
],
Expand Down Expand Up @@ -294,7 +299,8 @@ namespace ts.tscWatch {
referencedMap: {},
exportedModulesMap: {},
semanticDiagnosticsPerFile: [libFile.path, file1.path, file2.path]
}
},
version
})
}
],
Expand All @@ -315,7 +321,8 @@ namespace ts.tscWatch {
referencedMap: {},
exportedModulesMap: {},
semanticDiagnosticsPerFile: [libFile.path, file1.path, file2.path]
}
},
version
})
}
],
Expand Down Expand Up @@ -370,7 +377,8 @@ namespace ts.tscWatch {
file1.path,
file2ReuasableError
]
}
},
version
})
}
],
Expand All @@ -395,7 +403,8 @@ namespace ts.tscWatch {
file2ReuasableError,
file1.path
]
}
},
version
})
}
],
Expand Down Expand Up @@ -435,7 +444,8 @@ namespace ts.tscWatch {
{ pos: 0, end: outFile.content.length, kind: BundleFileSectionKind.Text }
]
},
}
},
version
})
}
],
Expand Down