Skip to content

Commit 7d103a1

Browse files
committed
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
1 parent 264bd5d commit 7d103a1

File tree

16 files changed

+131
-10
lines changed

16 files changed

+131
-10
lines changed

src/compiler/parser.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4427,13 +4427,10 @@ module ts {
44274427
return getSourceFileFromCache(filename, canonicalName, /*useAbsolutePath*/ false);
44284428
}
44294429
else {
4430-
// if --noResolve is not specified check if we have file for absolute path
4431-
if (!options.noResolve) {
4432-
var normalizedAbsolutePath = getNormalizedAbsolutePath(filename, host.getCurrentDirectory());
4433-
var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
4434-
if (hasProperty(filesByName, canonicalAbsolutePath)) {
4435-
return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true);
4436-
}
4430+
var normalizedAbsolutePath = getNormalizedAbsolutePath(filename, host.getCurrentDirectory());
4431+
var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
4432+
if (hasProperty(filesByName, canonicalAbsolutePath)) {
4433+
return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true);
44374434
}
44384435

44394436
// We haven't looked for this file, do so now and cache result
@@ -4443,10 +4440,11 @@ module ts {
44434440
});
44444441
if (file) {
44454442
seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib;
4446-
if (!options.noResolve) {
4447-
// Set the source file for normalized absolute path
4448-
filesByName[canonicalAbsolutePath] = file;
44494443

4444+
// Set the source file for normalized absolute path
4445+
filesByName[canonicalAbsolutePath] = file;
4446+
4447+
if (!options.noResolve) {
44504448
var basePath = getDirectoryPath(filename);
44514449
processReferencedFiles(file, basePath);
44524450
processImportedModules(file, basePath);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var test = (function () {
2+
function test() {
3+
}
4+
return test;
5+
})();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare class test {
2+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"scenario": "referenceResolutionSameFileTwice",
3+
"projectRoot": "tests/cases/projects/ReferenceResolution/",
4+
"inputFiles": [
5+
"test.ts",
6+
"../ReferenceResolution/test.ts"
7+
],
8+
"declaration": true,
9+
"baselineCheck": true,
10+
"resolvedInputFiles": [
11+
"lib.d.ts",
12+
"test.ts"
13+
],
14+
"emittedFiles": [
15+
"test.js",
16+
"test.d.ts"
17+
]
18+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var test = (function () {
2+
function test() {
3+
}
4+
return test;
5+
})();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare class test {
2+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"scenario": "referenceResolutionSameFileTwice",
3+
"projectRoot": "tests/cases/projects/ReferenceResolution/",
4+
"inputFiles": [
5+
"test.ts",
6+
"../ReferenceResolution/test.ts"
7+
],
8+
"declaration": true,
9+
"baselineCheck": true,
10+
"resolvedInputFiles": [
11+
"lib.d.ts",
12+
"test.ts"
13+
],
14+
"emittedFiles": [
15+
"test.js",
16+
"test.d.ts"
17+
]
18+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var test = (function () {
2+
function test() {
3+
}
4+
return test;
5+
})();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare class test {
2+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"scenario": "referenceResolutionSameFileTwice_NoResolve",
3+
"projectRoot": "tests/cases/projects/ReferenceResolution/",
4+
"inputFiles": [
5+
"test.ts",
6+
"../ReferenceResolution/test.ts"
7+
],
8+
"declaration": true,
9+
"baselineCheck": true,
10+
"resolvedInputFiles": [
11+
"lib.d.ts",
12+
"test.ts"
13+
],
14+
"emittedFiles": [
15+
"test.js",
16+
"test.d.ts"
17+
]
18+
}

0 commit comments

Comments
 (0)