Skip to content

Commit a5fd3e9

Browse files
committed
Handle out and outFile options correctly in tsbuild
1 parent b6129b4 commit a5fd3e9

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

src/compiler/program.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,9 @@ namespace ts {
676676
const parsedRef = parseProjectReferenceConfigFile(ref);
677677
resolvedProjectReferences!.push(parsedRef);
678678
if (parsedRef) {
679-
if (parsedRef.commandLine.options.outFile) {
680-
const dtsOutfile = changeExtension(parsedRef.commandLine.options.outFile, ".d.ts");
679+
const out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out;
680+
if (out) {
681+
const dtsOutfile = changeExtension(out, ".d.ts");
681682
processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
682683
}
683684
addProjectReferenceRedirects(parsedRef.commandLine, projectReferenceRedirects);
@@ -1244,6 +1245,13 @@ namespace ts {
12441245
}
12451246
resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
12461247
resolvedProjectReferences = oldProgram.getResolvedProjectReferences();
1248+
if (resolvedProjectReferences) {
1249+
resolvedProjectReferences.forEach(ref => {
1250+
if (ref) {
1251+
addProjectReferenceRedirects(ref.commandLine, projectReferenceRedirects);
1252+
}
1253+
});
1254+
}
12471255

12481256
sourceFileToPackageName = oldProgram.sourceFileToPackageName;
12491257
redirectTargetsMap = oldProgram.redirectTargetsMap;
@@ -1299,12 +1307,13 @@ namespace ts {
12991307
const ref = projectReferences[i];
13001308
const resolvedRefOpts = resolvedProjectReferences![i]!.commandLine;
13011309
if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) {
1310+
const out = resolvedRefOpts.options.outFile || resolvedRefOpts.options.out;
13021311
// Upstream project didn't have outFile set -- skip (error will have been issued earlier)
1303-
if (!resolvedRefOpts.options.outFile) continue;
1312+
if (!out) continue;
13041313

1305-
const dtsFilename = changeExtension(resolvedRefOpts.options.outFile, ".d.ts");
1306-
const js = host.readFile(resolvedRefOpts.options.outFile) || `/* Input file ${resolvedRefOpts.options.outFile} was missing */\r\n`;
1307-
const jsMapPath = resolvedRefOpts.options.outFile + ".map"; // TODO: try to read sourceMappingUrl comment from the file
1314+
const dtsFilename = changeExtension(out, ".d.ts");
1315+
const js = host.readFile(out) || `/* Input file ${out} was missing */\r\n`;
1316+
const jsMapPath = out + ".map"; // TODO: try to read sourceMappingUrl comment from the file
13081317
const jsMap = host.readFile(jsMapPath);
13091318
const dts = host.readFile(dtsFilename) || `/* Input file ${dtsFilename} was missing */\r\n`;
13101319
const dtsMapPath = dtsFilename + ".map";
@@ -2446,9 +2455,10 @@ namespace ts {
24462455
createDiagnosticForReference(i, Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path);
24472456
}
24482457
if (ref.prepend) {
2449-
if (resolvedRefOpts.outFile) {
2450-
if (!host.fileExists(resolvedRefOpts.outFile)) {
2451-
createDiagnosticForReference(i, Diagnostics.Output_file_0_from_project_1_does_not_exist, resolvedRefOpts.outFile, ref.path);
2458+
const out = resolvedRefOpts.outFile || resolvedRefOpts.out;
2459+
if (out) {
2460+
if (!host.fileExists(out)) {
2461+
createDiagnosticForReference(i, Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path);
24522462
}
24532463
}
24542464
else {

src/compiler/tsbuild.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,17 @@ namespace ts {
285285
}
286286

287287
function getOutFileOutputs(project: ParsedCommandLine): ReadonlyArray<string> {
288-
if (!project.options.outFile) {
288+
const out = project.options.outFile || project.options.out;
289+
if (!out) {
289290
return Debug.fail("outFile must be set");
290291
}
291292
const outputs: string[] = [];
292-
outputs.push(project.options.outFile);
293+
outputs.push(out);
293294
if (project.options.sourceMap) {
294-
outputs.push(`${project.options.outFile}.map`);
295+
outputs.push(`${out}.map`);
295296
}
296297
if (getEmitDeclarations(project.options)) {
297-
const dts = changeExtension(project.options.outFile, Extension.Dts);
298+
const dts = changeExtension(out, Extension.Dts);
298299
outputs.push(dts);
299300
if (project.options.declarationMap) {
300301
outputs.push(`${dts}.map`);
@@ -1248,7 +1249,7 @@ namespace ts {
12481249
}
12491250

12501251
export function getAllProjectOutputs(project: ParsedCommandLine): ReadonlyArray<string> {
1251-
if (project.options.outFile) {
1252+
if (project.options.outFile || project.options.out) {
12521253
return getOutFileOutputs(project);
12531254
}
12541255
else {

0 commit comments

Comments
 (0)