mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 10:58:20 -05:00
Merge pull request #31191 from Microsoft/fileFromNodeModules
Include only files that can be emitted into the source file directory check for composite projects
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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 {};
|
||||
@@ -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))
|
||||
|
||||
@@ -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
tests/cases/compiler/compositeWithNodeModulesSourceFile.ts
Normal file
13
tests/cases/compiler/compositeWithNodeModulesSourceFile.ts
Normal file
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user