Skip to content

Commit 9daf635

Browse files
committed
Verify and fix scenario when .js and .ts files with same name are present and tsconfig doesnt specify any filenames
1 parent bc48c7c commit 9daf635

12 files changed

Lines changed: 51 additions & 2 deletions

File tree

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ namespace ts {
474474
}
475475
else {
476476
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
477-
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
477+
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)).concat(host.readDirectory(basePath, ".js", exclude));
478478
for (let i = 0; i < sysFiles.length; i++) {
479479
let name = sysFiles[i];
480480
if (fileExtensionIs(name, ".js")) {

src/harness/projectsRunner.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,13 @@ class ProjectRunner extends RunnerBase {
263263
}
264264

265265
function readDirectory(rootDir: string, extension: string, exclude: string[]): string[] {
266-
return Harness.IO.readDirectory(getFileNameInTheProjectTest(rootDir), extension, exclude);
266+
let harnessReadDirectoryResult = Harness.IO.readDirectory(getFileNameInTheProjectTest(rootDir), extension, exclude);
267+
let result: string[] = [];
268+
for (let i = 0; i < harnessReadDirectoryResult.length; i++) {
269+
result[i] = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, harnessReadDirectoryResult[i],
270+
getCurrentDirectory(), Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
271+
}
272+
return result;
267273
}
268274

269275
function fileExists(fileName: string): boolean {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare var test: number;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var test = 10;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json",
3+
"projectRoot": "tests/cases/projects/jsFileCompilation",
4+
"baselineCheck": true,
5+
"declaration": true,
6+
"project": "SameNameFilesNotSpecified",
7+
"resolvedInputFiles": [
8+
"lib.d.ts",
9+
"SameNameFilesNotSpecified/a.ts"
10+
],
11+
"emittedFiles": [
12+
"SameNameFilesNotSpecified/a.js",
13+
"SameNameFilesNotSpecified/a.d.ts"
14+
]
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare var test: number;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var test = 10;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json",
3+
"projectRoot": "tests/cases/projects/jsFileCompilation",
4+
"baselineCheck": true,
5+
"declaration": true,
6+
"project": "SameNameFilesNotSpecified",
7+
"resolvedInputFiles": [
8+
"lib.d.ts",
9+
"SameNameFilesNotSpecified/a.ts"
10+
],
11+
"emittedFiles": [
12+
"SameNameFilesNotSpecified/a.js",
13+
"SameNameFilesNotSpecified/a.d.ts"
14+
]
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json",
3+
"projectRoot": "tests/cases/projects/jsFileCompilation",
4+
"baselineCheck": true,
5+
"declaration": true,
6+
"project": "SameNameFilesNotSpecified"
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
var test1 = 10; // Shouldnt get compiled

0 commit comments

Comments
 (0)