Verify and fix scenario when .js and .ts files with same name are present and tsconfig doesnt specify any filenames

This commit is contained in:
Sheetal Nandi 2015-09-16 11:50:12 -07:00
parent bc48c7c9f0
commit 9daf635e5e
12 changed files with 51 additions and 2 deletions

View file

@ -474,7 +474,7 @@ namespace ts {
}
else {
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)).concat(host.readDirectory(basePath, ".js", exclude));
for (let i = 0; i < sysFiles.length; i++) {
let name = sysFiles[i];
if (fileExtensionIs(name, ".js")) {

View file

@ -263,7 +263,13 @@ class ProjectRunner extends RunnerBase {
}
function readDirectory(rootDir: string, extension: string, exclude: string[]): string[] {
return Harness.IO.readDirectory(getFileNameInTheProjectTest(rootDir), extension, exclude);
let harnessReadDirectoryResult = Harness.IO.readDirectory(getFileNameInTheProjectTest(rootDir), extension, exclude);
let result: string[] = [];
for (let i = 0; i < harnessReadDirectoryResult.length; i++) {
result[i] = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, harnessReadDirectoryResult[i],
getCurrentDirectory(), Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
}
return result;
}
function fileExists(fileName: string): boolean {

View file

@ -0,0 +1,15 @@
{
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json",
"projectRoot": "tests/cases/projects/jsFileCompilation",
"baselineCheck": true,
"declaration": true,
"project": "SameNameFilesNotSpecified",
"resolvedInputFiles": [
"lib.d.ts",
"SameNameFilesNotSpecified/a.ts"
],
"emittedFiles": [
"SameNameFilesNotSpecified/a.js",
"SameNameFilesNotSpecified/a.d.ts"
]
}

View file

@ -0,0 +1,15 @@
{
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json",
"projectRoot": "tests/cases/projects/jsFileCompilation",
"baselineCheck": true,
"declaration": true,
"project": "SameNameFilesNotSpecified",
"resolvedInputFiles": [
"lib.d.ts",
"SameNameFilesNotSpecified/a.ts"
],
"emittedFiles": [
"SameNameFilesNotSpecified/a.js",
"SameNameFilesNotSpecified/a.d.ts"
]
}

View file

@ -0,0 +1,7 @@
{
"scenario": "Verify when same named .ts and .js file exists in the folder but no file is specified in tsconfig.json",
"projectRoot": "tests/cases/projects/jsFileCompilation",
"baselineCheck": true,
"declaration": true,
"project": "SameNameFilesNotSpecified"
}

View file

@ -0,0 +1 @@
var test1 = 10; // Shouldnt get compiled

View file

@ -0,0 +1 @@
var test = 10;