mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Merge pull request #11957 from Microsoft/fix_realpathmap
Fix realPathMap in test harness: Must be used in `directoryExists`
This commit is contained in:
commit
49be2e2c5d
@ -1029,7 +1029,7 @@ namespace Harness {
|
||||
},
|
||||
realpath: realPathMap && ((f: string) => {
|
||||
const path = ts.toPath(f, currentDirectory, getCanonicalFileName);
|
||||
return realPathMap.contains(path) ? realPathMap.get(path) : path;
|
||||
return realPathMap.get(path) || path;
|
||||
}),
|
||||
directoryExists: dir => {
|
||||
let path = ts.toPath(dir, currentDirectory, getCanonicalFileName);
|
||||
@ -1037,13 +1037,7 @@ namespace Harness {
|
||||
if (path[path.length - 1] === "/") {
|
||||
path = <ts.Path>path.substr(0, path.length - 1);
|
||||
}
|
||||
let exists = false;
|
||||
fileMap.forEachValue(key => {
|
||||
if (key.indexOf(path) === 0 && key[path.length] === "/") {
|
||||
exists = true;
|
||||
}
|
||||
});
|
||||
return exists;
|
||||
return mapHasFileInDirectory(path, fileMap) || mapHasFileInDirectory(path, realPathMap);
|
||||
},
|
||||
getDirectories: d => {
|
||||
const path = ts.toPath(d, currentDirectory, getCanonicalFileName);
|
||||
@ -1064,6 +1058,19 @@ namespace Harness {
|
||||
};
|
||||
}
|
||||
|
||||
function mapHasFileInDirectory(directoryPath: ts.Path, map: ts.FileMap<any>): boolean {
|
||||
if (!map) {
|
||||
return false;
|
||||
}
|
||||
let exists = false;
|
||||
map.forEachValue(fileName => {
|
||||
if (!exists && ts.startsWith(fileName, directoryPath) && fileName[directoryPath.length] === "/") {
|
||||
exists = true;
|
||||
}
|
||||
});
|
||||
return exists;
|
||||
}
|
||||
|
||||
interface HarnessOptions {
|
||||
useCaseSensitiveFileNames?: boolean;
|
||||
includeBuiltFile?: string;
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
/src/library-b/index.ts(1,23): error TS2307: Cannot find module 'library-a'.
|
||||
|
||||
|
||||
==== /src/app.ts (0 errors) ====
|
||||
import { MyClass } from "./library-a";
|
||||
import { MyClass2 } from "./library-b";
|
||||
|
||||
let x: MyClass;
|
||||
let y: MyClass2;
|
||||
x = y;
|
||||
y = x;
|
||||
==== /src/library-a/index.ts (0 errors) ====
|
||||
|
||||
export class MyClass{}
|
||||
|
||||
==== /src/library-b/index.ts (1 errors) ====
|
||||
import {MyClass} from "library-a";
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'library-a'.
|
||||
export { MyClass as MyClass2 }
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
//// [index.ts]
|
||||
|
||||
export class MyClass{}
|
||||
export class MyClass { private x: number; }
|
||||
|
||||
//// [index.ts]
|
||||
import {MyClass} from "library-a";
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
=== /src/app.ts ===
|
||||
import { MyClass } from "./library-a";
|
||||
>MyClass : Symbol(MyClass, Decl(app.ts, 0, 8))
|
||||
|
||||
import { MyClass2 } from "./library-b";
|
||||
>MyClass2 : Symbol(MyClass2, Decl(app.ts, 1, 8))
|
||||
|
||||
let x: MyClass;
|
||||
>x : Symbol(x, Decl(app.ts, 3, 3))
|
||||
>MyClass : Symbol(MyClass, Decl(app.ts, 0, 8))
|
||||
|
||||
let y: MyClass2;
|
||||
>y : Symbol(y, Decl(app.ts, 4, 3))
|
||||
>MyClass2 : Symbol(MyClass2, Decl(app.ts, 1, 8))
|
||||
|
||||
x = y;
|
||||
>x : Symbol(x, Decl(app.ts, 3, 3))
|
||||
>y : Symbol(y, Decl(app.ts, 4, 3))
|
||||
|
||||
y = x;
|
||||
>y : Symbol(y, Decl(app.ts, 4, 3))
|
||||
>x : Symbol(x, Decl(app.ts, 3, 3))
|
||||
|
||||
=== /src/library-a/index.ts ===
|
||||
|
||||
export class MyClass { private x: number; }
|
||||
>MyClass : Symbol(MyClass, Decl(index.ts, 0, 0))
|
||||
>x : Symbol(MyClass.x, Decl(index.ts, 1, 22))
|
||||
|
||||
=== /src/library-b/index.ts ===
|
||||
import {MyClass} from "library-a";
|
||||
>MyClass : Symbol(MyClass, Decl(index.ts, 0, 8))
|
||||
|
||||
export { MyClass as MyClass2 }
|
||||
>MyClass : Symbol(MyClass2, Decl(index.ts, 1, 8))
|
||||
>MyClass2 : Symbol(MyClass2, Decl(index.ts, 1, 8))
|
||||
|
||||
@ -26,74 +26,7 @@
|
||||
"File '/src/library-b/node_modules/library-a.tsx' does not exist.",
|
||||
"File '/src/library-b/node_modules/library-a.d.ts' does not exist.",
|
||||
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
|
||||
"File '/src/library-b/node_modules/library-a/index.ts' does not exist.",
|
||||
"File '/src/library-b/node_modules/library-a/index.tsx' does not exist.",
|
||||
"File '/src/library-b/node_modules/library-a/index.d.ts' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a.ts' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a.tsx' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a.d.ts' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a/package.json' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a/index.ts' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a/index.tsx' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a/index.d.ts' does not exist.",
|
||||
"File '/src/node_modules/library-a.ts' does not exist.",
|
||||
"File '/src/node_modules/library-a.tsx' does not exist.",
|
||||
"File '/src/node_modules/library-a.d.ts' does not exist.",
|
||||
"File '/src/node_modules/library-a/package.json' does not exist.",
|
||||
"File '/src/node_modules/library-a/index.ts' does not exist.",
|
||||
"File '/src/node_modules/library-a/index.tsx' does not exist.",
|
||||
"File '/src/node_modules/library-a/index.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a.tsx' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a/index.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a/index.tsx' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a/index.d.ts' does not exist.",
|
||||
"File '/node_modules/library-a.ts' does not exist.",
|
||||
"File '/node_modules/library-a.tsx' does not exist.",
|
||||
"File '/node_modules/library-a.d.ts' does not exist.",
|
||||
"File '/node_modules/library-a/package.json' does not exist.",
|
||||
"File '/node_modules/library-a/index.ts' does not exist.",
|
||||
"File '/node_modules/library-a/index.tsx' does not exist.",
|
||||
"File '/node_modules/library-a/index.d.ts' does not exist.",
|
||||
"File '/node_modules/@types/library-a.ts' does not exist.",
|
||||
"File '/node_modules/@types/library-a.tsx' does not exist.",
|
||||
"File '/node_modules/@types/library-a.d.ts' does not exist.",
|
||||
"File '/node_modules/@types/library-a/package.json' does not exist.",
|
||||
"File '/node_modules/@types/library-a/index.ts' does not exist.",
|
||||
"File '/node_modules/@types/library-a/index.tsx' does not exist.",
|
||||
"File '/node_modules/@types/library-a/index.d.ts' does not exist.",
|
||||
"Loading module 'library-a' from 'node_modules' folder.",
|
||||
"File '/src/library-b/node_modules/library-a.js' does not exist.",
|
||||
"File '/src/library-b/node_modules/library-a.jsx' does not exist.",
|
||||
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
|
||||
"File '/src/library-b/node_modules/library-a/index.js' does not exist.",
|
||||
"File '/src/library-b/node_modules/library-a/index.jsx' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a.js' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a.jsx' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a/package.json' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a/index.js' does not exist.",
|
||||
"File '/src/library-b/node_modules/@types/library-a/index.jsx' does not exist.",
|
||||
"File '/src/node_modules/library-a.js' does not exist.",
|
||||
"File '/src/node_modules/library-a.jsx' does not exist.",
|
||||
"File '/src/node_modules/library-a/package.json' does not exist.",
|
||||
"File '/src/node_modules/library-a/index.js' does not exist.",
|
||||
"File '/src/node_modules/library-a/index.jsx' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a.js' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a.jsx' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a/index.js' does not exist.",
|
||||
"File '/src/node_modules/@types/library-a/index.jsx' does not exist.",
|
||||
"File '/node_modules/library-a.js' does not exist.",
|
||||
"File '/node_modules/library-a.jsx' does not exist.",
|
||||
"File '/node_modules/library-a/package.json' does not exist.",
|
||||
"File '/node_modules/library-a/index.js' does not exist.",
|
||||
"File '/node_modules/library-a/index.jsx' does not exist.",
|
||||
"File '/node_modules/@types/library-a.js' does not exist.",
|
||||
"File '/node_modules/@types/library-a.jsx' does not exist.",
|
||||
"File '/node_modules/@types/library-a/package.json' does not exist.",
|
||||
"File '/node_modules/@types/library-a/index.js' does not exist.",
|
||||
"File '/node_modules/@types/library-a/index.jsx' does not exist.",
|
||||
"======== Module name 'library-a' was not resolved. ========"
|
||||
"File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.",
|
||||
"Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'",
|
||||
"======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========"
|
||||
]
|
||||
39
tests/baselines/reference/moduleResolutionWithSymlinks.types
Normal file
39
tests/baselines/reference/moduleResolutionWithSymlinks.types
Normal file
@ -0,0 +1,39 @@
|
||||
=== /src/app.ts ===
|
||||
import { MyClass } from "./library-a";
|
||||
>MyClass : typeof MyClass
|
||||
|
||||
import { MyClass2 } from "./library-b";
|
||||
>MyClass2 : typeof MyClass
|
||||
|
||||
let x: MyClass;
|
||||
>x : MyClass
|
||||
>MyClass : MyClass
|
||||
|
||||
let y: MyClass2;
|
||||
>y : MyClass
|
||||
>MyClass2 : MyClass
|
||||
|
||||
x = y;
|
||||
>x = y : MyClass
|
||||
>x : MyClass
|
||||
>y : MyClass
|
||||
|
||||
y = x;
|
||||
>y = x : MyClass
|
||||
>y : MyClass
|
||||
>x : MyClass
|
||||
|
||||
=== /src/library-a/index.ts ===
|
||||
|
||||
export class MyClass { private x: number; }
|
||||
>MyClass : MyClass
|
||||
>x : number
|
||||
|
||||
=== /src/library-b/index.ts ===
|
||||
import {MyClass} from "library-a";
|
||||
>MyClass : typeof MyClass
|
||||
|
||||
export { MyClass as MyClass2 }
|
||||
>MyClass : typeof MyClass
|
||||
>MyClass2 : typeof MyClass
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
// @filename: /src/library-a/index.ts
|
||||
// @symlink: /src/library-b/node_modules/library-a/index.ts
|
||||
export class MyClass{}
|
||||
export class MyClass { private x: number; }
|
||||
|
||||
// @filename: /src/library-b/index.ts
|
||||
import {MyClass} from "library-a";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user