Skip to content

Commit 7817465

Browse files
committed
Do not add source files to container only project
1 parent 3a2f7c0 commit 7817465

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/compiler/program.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -694,12 +694,14 @@ namespace ts {
694694
if (!resolvedProjectReferences) {
695695
resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
696696
}
697-
for (const parsedRef of resolvedProjectReferences) {
698-
if (parsedRef) {
699-
const out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out;
700-
if (out) {
701-
const dtsOutfile = changeExtension(out, ".d.ts");
702-
processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
697+
if (rootNames.length) {
698+
for (const parsedRef of resolvedProjectReferences) {
699+
if (parsedRef) {
700+
const out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out;
701+
if (out) {
702+
const dtsOutfile = changeExtension(out, ".d.ts");
703+
processSourceFile(dtsOutfile, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined);
704+
}
703705
}
704706
}
705707
}
@@ -708,7 +710,7 @@ namespace ts {
708710
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false));
709711

710712
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
711-
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, host);
713+
const typeReferences: string[] = rootNames.length ? getAutomaticTypeDirectiveNames(options, host) : emptyArray;
712714

713715
if (typeReferences.length) {
714716
// This containingFilename needs to match with the one used in managed-side
@@ -724,7 +726,7 @@ namespace ts {
724726
// - The '--noLib' flag is used.
725727
// - A 'no-default-lib' reference comment is encountered in
726728
// processing the root files.
727-
if (!skipDefaultLib) {
729+
if (rootNames.length && !skipDefaultLib) {
728730
// If '--lib' is not specified, include default library file according to '--target'
729731
// otherwise, using options specified in '--lib' instead of '--target' default library file
730732
const defaultLibraryFileName = getDefaultLibraryFileName();

src/testRunner/unittests/tsserverProjectSystem.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10520,6 +10520,8 @@ declare class TestLib {
1052010520
}).response;
1052110521
assert.deepEqual(semanticDiagnostics, []);
1052210522
});
10523+
const containerProject = service.configuredProjects.get(containerConfig.path)!;
10524+
checkProjectActualFiles(containerProject, [containerConfig.path]);
1052310525
});
1052410526
});
1052510527

0 commit comments

Comments
 (0)