Skip to content

Commit a469fd8

Browse files
committed
Should not report that files are not part of config for files that are not going to be emitted
1 parent 076dde4 commit a469fd8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/compiler/program.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,9 +1008,15 @@ namespace ts {
10081008
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
10091009
}
10101010

1011+
function isValidSourceFileForEmit(file: SourceFile) {
1012+
// source file is allowed to be emitted and its not source of project reference redirect
1013+
return sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) &&
1014+
!isSourceOfProjectReferenceRedirect(file.fileName);
1015+
}
1016+
10111017
function getCommonSourceDirectory() {
10121018
if (commonSourceDirectory === undefined) {
1013-
const emittedFiles = filter(files, file => sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect));
1019+
const emittedFiles = filter(files, file => isValidSourceFileForEmit(file));
10141020
if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) {
10151021
// If a rootDir is specified use it as the commonSourceDirectory
10161022
commonSourceDirectory = getNormalizedAbsolutePath(options.rootDir, currentDirectory);
@@ -2933,8 +2939,7 @@ namespace ts {
29332939
const rootPaths = arrayToSet(rootNames, toPath);
29342940
for (const file of files) {
29352941
// Ignore file that is not emitted
2936-
if (!sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue;
2937-
if (!rootPaths.has(file.path)) {
2942+
if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) {
29382943
addProgramDiagnosticAtRefPath(
29392944
file,
29402945
rootPaths,

src/testRunner/unittests/tsserver/projectReferenceErrors.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ fnErr();
313313
const usageConfig: File = {
314314
path: `${usageLocation}/tsconfig.json`,
315315
content: JSON.stringify({
316+
compilerOptions: { composite: true },
316317
references: [{ path: "../dependency" }]
317318
})
318319
};
@@ -381,7 +382,7 @@ fnErr();
381382
const usageConfig: File = {
382383
path: `${usageLocation}/tsconfig.json`,
383384
content: JSON.stringify({
384-
compilerOptions: { outFile: "../usage.js" },
385+
compilerOptions: { composite: true, outFile: "../usage.js" },
385386
references: [{ path: "../dependency" }]
386387
})
387388
};

0 commit comments

Comments
 (0)