Simplify test and add explanatory assertion

This commit is contained in:
Benjamin Lichtman 2017-12-28 11:22:41 -08:00
parent 90e11f0797
commit b9ea3471a4
2 changed files with 2 additions and 5 deletions

View File

@ -1185,13 +1185,9 @@ namespace ts.projectSystem {
});
it("external project for dynamic file", () => {
const file1 = {
path: "/a/b/f1.ts",
content: "let x =1;"
};
const externalProjectName = "^ScriptDocument1 file1.ts";
const externalFiles = toExternalFiles(["^ScriptDocument1 file1.ts"]);
const host = createServerHost([file1]);
const host = createServerHost([]);
const projectService = createProjectService(host);
projectService.openExternalProject({
rootFiles: externalFiles,

View File

@ -1779,6 +1779,7 @@ namespace ts.server {
const isDynamic = isDynamicFileName(fileName);
Debug.assert(isRootedDiskPath(fileName) || isDynamic || openedByClient, "Script info with non-dynamic relative file name can only be open script info");
Debug.assert(!isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "Open script files with non rooted disk path opened with current directory context cannot have same canonical names");
Debug.assert(!isDynamic || this.currentDirectory === currentDirectory, "Dynamic files must always have current directory context since containing external project name will always match the script info name.");
// If the file is not opened by client and the file doesnot exist on the disk, return
if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) {
return;