Remove the --noResolve check when finding the file.

--noResolve is only for ///reference and import file resolution to resolve files from disk
but the file identity is always determined before creating duplicate source file for same file paths
This commit is contained in:
Sheetal Nandi 2014-11-20 15:43:07 -08:00
parent 264bd5db7c
commit 7d103a1a45
16 changed files with 131 additions and 10 deletions

View File

@ -4427,13 +4427,10 @@ module ts {
return getSourceFileFromCache(filename, canonicalName, /*useAbsolutePath*/ false);
}
else {
// if --noResolve is not specified check if we have file for absolute path
if (!options.noResolve) {
var normalizedAbsolutePath = getNormalizedAbsolutePath(filename, host.getCurrentDirectory());
var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
if (hasProperty(filesByName, canonicalAbsolutePath)) {
return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true);
}
var normalizedAbsolutePath = getNormalizedAbsolutePath(filename, host.getCurrentDirectory());
var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
if (hasProperty(filesByName, canonicalAbsolutePath)) {
return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true);
}
// We haven't looked for this file, do so now and cache result
@ -4443,10 +4440,11 @@ module ts {
});
if (file) {
seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib;
if (!options.noResolve) {
// Set the source file for normalized absolute path
filesByName[canonicalAbsolutePath] = file;
// Set the source file for normalized absolute path
filesByName[canonicalAbsolutePath] = file;
if (!options.noResolve) {
var basePath = getDirectoryPath(filename);
processReferencedFiles(file, basePath);
processImportedModules(file, basePath);

View File

@ -0,0 +1,5 @@
var test = (function () {
function test() {
}
return test;
})();

View File

@ -0,0 +1,2 @@
declare class test {
}

View File

@ -0,0 +1,18 @@
{
"scenario": "referenceResolutionSameFileTwice",
"projectRoot": "tests/cases/projects/ReferenceResolution/",
"inputFiles": [
"test.ts",
"../ReferenceResolution/test.ts"
],
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.d.ts",
"test.ts"
],
"emittedFiles": [
"test.js",
"test.d.ts"
]
}

View File

@ -0,0 +1,5 @@
var test = (function () {
function test() {
}
return test;
})();

View File

@ -0,0 +1,2 @@
declare class test {
}

View File

@ -0,0 +1,18 @@
{
"scenario": "referenceResolutionSameFileTwice",
"projectRoot": "tests/cases/projects/ReferenceResolution/",
"inputFiles": [
"test.ts",
"../ReferenceResolution/test.ts"
],
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.d.ts",
"test.ts"
],
"emittedFiles": [
"test.js",
"test.d.ts"
]
}

View File

@ -0,0 +1,5 @@
var test = (function () {
function test() {
}
return test;
})();

View File

@ -0,0 +1,2 @@
declare class test {
}

View File

@ -0,0 +1,18 @@
{
"scenario": "referenceResolutionSameFileTwice_NoResolve",
"projectRoot": "tests/cases/projects/ReferenceResolution/",
"inputFiles": [
"test.ts",
"../ReferenceResolution/test.ts"
],
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.d.ts",
"test.ts"
],
"emittedFiles": [
"test.js",
"test.d.ts"
]
}

View File

@ -0,0 +1,5 @@
var test = (function () {
function test() {
}
return test;
})();

View File

@ -0,0 +1,2 @@
declare class test {
}

View File

@ -0,0 +1,18 @@
{
"scenario": "referenceResolutionSameFileTwice_NoResolve",
"projectRoot": "tests/cases/projects/ReferenceResolution/",
"inputFiles": [
"test.ts",
"../ReferenceResolution/test.ts"
],
"declaration": true,
"baselineCheck": true,
"resolvedInputFiles": [
"lib.d.ts",
"test.ts"
],
"emittedFiles": [
"test.js",
"test.d.ts"
]
}

View File

@ -0,0 +1,10 @@
{
"scenario": "referenceResolutionSameFileTwice",
"projectRoot": "tests/cases/projects/ReferenceResolution/",
"inputFiles": [
"test.ts",
"../ReferenceResolution/test.ts"
],
"declaration": true,
"baselineCheck": true
}

View File

@ -0,0 +1,11 @@
{
"scenario": "referenceResolutionSameFileTwice_NoResolve",
"projectRoot": "tests/cases/projects/ReferenceResolution/",
"inputFiles": [
"test.ts",
"../ReferenceResolution/test.ts"
],
"noResolve": true,
"declaration": true,
"baselineCheck": true
}

View File

@ -0,0 +1,2 @@
class test {
}