Skip to content

Include only files that can be emitted into the source file directory check for composite projects #31191

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 2 commits into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2768,10 +2768,8 @@ namespace ts {
if (options.composite) {
const rootPaths = rootNames.map(toPath);
for (const file of files) {
// Ignore declaration files
if (file.isDeclarationFile) continue;
// Ignore json file thats from project reference
if (isJsonSourceFile(file) && getResolvedProjectReferenceToRedirect(file.fileName)) continue;
// Ignore file that is not emitted
if (!sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) continue;
if (rootPaths.indexOf(file.path) === -1) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName));
}
Expand Down
20 changes: 20 additions & 0 deletions tests/baselines/reference/compositeWithNodeModulesSourceFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//// [tests/cases/compiler/compositeWithNodeModulesSourceFile.ts] ////

//// [index.ts]
export class c { }

//// [test.ts]
import myModule = require("myModule");
new myModule.c();



//// [test.js]
"use strict";
exports.__esModule = true;
var myModule = require("myModule");
new myModule.c();


//// [test.d.ts]
export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
=== /foo/test.ts ===
import myModule = require("myModule");
>myModule : Symbol(myModule, Decl(test.ts, 0, 0))

new myModule.c();
>myModule.c : Symbol(myModule.c, Decl(index.ts, 0, 0))
>myModule : Symbol(myModule, Decl(test.ts, 0, 0))
>c : Symbol(myModule.c, Decl(index.ts, 0, 0))


=== /foo/node_modules/myModule/index.ts ===
export class c { }
>c : Symbol(c, Decl(index.ts, 0, 0))

15 changes: 15 additions & 0 deletions tests/baselines/reference/compositeWithNodeModulesSourceFile.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
=== /foo/test.ts ===
import myModule = require("myModule");
>myModule : typeof myModule

new myModule.c();
>new myModule.c() : myModule.c
>myModule.c : typeof myModule.c
>myModule : typeof myModule
>c : typeof myModule.c


=== /foo/node_modules/myModule/index.ts ===
export class c { }
>c : c

13 changes: 13 additions & 0 deletions tests/cases/compiler/compositeWithNodeModulesSourceFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @filename: /foo/tsconfig.json
{
"compilerOptions": { "composite": true },
"exclude": [ "node_modules" ]
}

// @filename: /foo/node_modules/myModule/index.ts
export class c { }

// @filename: /foo/test.ts
import myModule = require("myModule");
new myModule.c();