mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Tests for unresolved imports from multiple places
This commit is contained in:
@@ -156,6 +156,33 @@ describe("unittests:: tsbuild:: cacheResolutions::", () => {
|
||||
caption: "modify e/ea/eaa/eaaa/x/y/z/randomFileForImport by adding import",
|
||||
edit: fs => prependText(fs, "/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface0 } from "pkg0";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify b/randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/b/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify c/ca/caa/randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/c/ca/caa/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify d/da/daa/daaa/x/y/z/randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/d/da/daa/daaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify e/ea/eaa/eaaa/x/y/z/randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "add file for unresolved import",
|
||||
edit: fs => {
|
||||
fs.mkdirpSync("/src/project/node_modules/pkg1");
|
||||
fs.writeFileSync("/src/project/node_modules/pkg1/index.d.ts", getPkgImportContent("Import", 1));
|
||||
},
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
@@ -273,43 +273,55 @@ function getFsMapWithSameResolutionFromMultiplePlaces(): { [path: string]: strin
|
||||
}),
|
||||
"/src/project/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/randomFileForImport.ts": getRandomFileContent(),
|
||||
"/src/project/a/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/b/ba/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/b/randomFileForImport.ts": getRandomFileContent(),
|
||||
"/src/project/c/ca/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/c/ca/caa/randomFileForImport.ts": getRandomFileContent(),
|
||||
"/src/project/c/ca/caa/caaa/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/c/cb/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/d/da/daa/daaa/x/y/z/randomFileForImport.ts": getRandomFileContent(),
|
||||
"/src/project/d/da/daa/daaa/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/d/da/daa/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/d/da/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/e/ea/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/e/ea/eaa/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/e/ea/eaa/eaaa/fileWithImports.ts": Utils.dedent`
|
||||
import type { ImportInterface0 } from "pkg0";
|
||||
import type { ImportInterface1 } from "pkg1";
|
||||
`,
|
||||
"/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts": getRandomFileContent(),
|
||||
"/src/project/node_modules/pkg0/index.d.ts": getPkgImportContent("Import", 0),
|
||||
|
||||
@@ -202,6 +202,39 @@ describe("unittests:: tsbuildWatch:: watchMode:: cacheResolutions::", () => {
|
||||
edit: sys => sys.prependFile("/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface0 } from "pkg0";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify b/randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/b/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify c/ca/caa/randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/c/ca/caa/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify d/da/daa/daaa/x/y/z/randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/d/da/daa/daaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify e/ea/eaa/eaaa/x/y/z/randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "add file for unresolved import and random edit",
|
||||
edit: sys => {
|
||||
sys.ensureFileOrFolder({ path: "/src/project/node_modules/pkg1/index.d.ts", content: getPkgImportContent("Import", 1) });
|
||||
sys.appendFile("/src/project/randomFileForImport.ts", `export const y = 10;`);
|
||||
},
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -252,6 +252,33 @@ describe("unittests:: tsc:: cacheResolutions::", () => {
|
||||
caption: "modify e/ea/eaa/eaaa/x/y/z/randomFileForImport by adding import",
|
||||
edit: fs => prependText(fs, "/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface0 } from "pkg0";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify b/randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/b/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify c/ca/caa/randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/c/ca/caa/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify d/da/daa/daaa/x/y/z/randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/d/da/daa/daaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "modify e/ea/eaa/eaaa/x/y/z/randomFileForImport by adding unresolved import",
|
||||
edit: fs => prependText(fs, "/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
},
|
||||
{
|
||||
caption: "add file for unresolved import",
|
||||
edit: fs => {
|
||||
fs.mkdirpSync("/src/project/node_modules/pkg1");
|
||||
fs.writeFileSync("/src/project/node_modules/pkg1/index.d.ts", getPkgImportContent("Import", 1));
|
||||
},
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
@@ -212,6 +212,42 @@ describe("unittests:: tsc-watch:: cacheResolutions::", () => {
|
||||
edit: sys => sys.prependFile("/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface0 } from "pkg0";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify b/randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/b/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify c/ca/caa/randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/c/ca/caa/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify d/da/daa/daaa/x/y/z/randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/d/da/daa/daaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "modify e/ea/eaa/eaaa/x/y/z/randomFileForImport by adding unresolved import",
|
||||
edit: sys => sys.prependFile("/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts", `import type { ImportInterface1 } from "pkg1";\n`),
|
||||
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
|
||||
},
|
||||
{
|
||||
caption: "add file for unresolved import and random edit",
|
||||
edit: sys => {
|
||||
sys.ensureFileOrFolder({ path: "/src/project/node_modules/pkg1/index.d.ts", content: getPkgImportContent("Import", 1) });
|
||||
sys.appendFile("/src/project/randomFileForImport.ts", `export const y = 10;`);
|
||||
},
|
||||
timeouts: sys => {
|
||||
sys.runQueuedTimeoutCallbacks(); // Failed lookups
|
||||
sys.runQueuedTimeoutCallbacks(); // actual update
|
||||
},
|
||||
},
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -292,6 +292,82 @@ describe("unittests:: tsserver:: cacheResolutions:: tsserverProjectSystem cachin
|
||||
});
|
||||
ts.server.updateProjectIfDirty(session.getProjectService().configuredProjects.get("/src/project/tsconfig.json")!);
|
||||
|
||||
session.logger.info("modify randomFileForImport by adding unresolved import");
|
||||
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
|
||||
command: ts.server.protocol.CommandTypes.Change,
|
||||
arguments: {
|
||||
file: "/src/project/randomFileForImport.ts",
|
||||
line: 1,
|
||||
offset: 1,
|
||||
endLine: 1,
|
||||
endOffset: 1,
|
||||
insertString: `import type { ImportInterface1 } from "pkg1";\n`,
|
||||
}
|
||||
});
|
||||
ts.server.updateProjectIfDirty(session.getProjectService().configuredProjects.get("/src/project/tsconfig.json")!);
|
||||
|
||||
session.logger.info("modify b/randomFileForImport by adding unresolved import");
|
||||
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
|
||||
command: ts.server.protocol.CommandTypes.Change,
|
||||
arguments: {
|
||||
file: "/src/project/b/randomFileForImport.ts",
|
||||
line: 1,
|
||||
offset: 1,
|
||||
endLine: 1,
|
||||
endOffset: 1,
|
||||
insertString: `import type { ImportInterface1 } from "pkg1";\n`,
|
||||
}
|
||||
});
|
||||
ts.server.updateProjectIfDirty(session.getProjectService().configuredProjects.get("/src/project/tsconfig.json")!);
|
||||
|
||||
session.logger.info("modify c/ca/caa/randomFileForImport by adding unresolved import");
|
||||
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
|
||||
command: ts.server.protocol.CommandTypes.Change,
|
||||
arguments: {
|
||||
file: "/src/project/c/ca/caa/randomFileForImport.ts",
|
||||
line: 1,
|
||||
offset: 1,
|
||||
endLine: 1,
|
||||
endOffset: 1,
|
||||
insertString: `import type { ImportInterface1 } from "pkg1";\n`,
|
||||
}
|
||||
});
|
||||
ts.server.updateProjectIfDirty(session.getProjectService().configuredProjects.get("/src/project/tsconfig.json")!);
|
||||
|
||||
session.logger.info("modify d/da/daa/daaa/x/y/z/randomFileForImport by adding unresolved import");
|
||||
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
|
||||
command: ts.server.protocol.CommandTypes.Change,
|
||||
arguments: {
|
||||
file: "/src/project/d/da/daa/daaa/x/y/z/randomFileForImport.ts",
|
||||
line: 1,
|
||||
offset: 1,
|
||||
endLine: 1,
|
||||
endOffset: 1,
|
||||
insertString: `import type { ImportInterface1 } from "pkg1";\n`,
|
||||
}
|
||||
});
|
||||
ts.server.updateProjectIfDirty(session.getProjectService().configuredProjects.get("/src/project/tsconfig.json")!);
|
||||
|
||||
session.logger.info("modify e/ea/eaa/eaaa/x/y/z/randomFileForImport by adding unresolved import");
|
||||
session.executeCommandSeq<ts.server.protocol.ChangeRequest>({
|
||||
command: ts.server.protocol.CommandTypes.Change,
|
||||
arguments: {
|
||||
file: "/src/project/e/ea/eaa/eaaa/x/y/z/randomFileForImport.ts",
|
||||
line: 1,
|
||||
offset: 1,
|
||||
endLine: 1,
|
||||
endOffset: 1,
|
||||
insertString: `import type { ImportInterface1 } from "pkg1";\n`,
|
||||
}
|
||||
});
|
||||
ts.server.updateProjectIfDirty(session.getProjectService().configuredProjects.get("/src/project/tsconfig.json")!);
|
||||
|
||||
session.logger.info("add file for unresolved import and random edit");
|
||||
host.ensureFileOrFolder({ path: "/src/project/node_modules/pkg1/index.d.ts", content: getPkgImportContent("Import", 1) });
|
||||
host.appendFile("/src/project/randomFileForImport.ts", `export const y = 10;`);
|
||||
host.runQueuedTimeoutCallbacks(); // Failed lookups
|
||||
host.runQueuedTimeoutCallbacks(); // actual update
|
||||
|
||||
baselineTsserverLogs("cacheResolutions", scenario, session);
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
+42558
-783
File diff suppressed because one or more lines are too long
+3443
-387
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+38599
-789
File diff suppressed because one or more lines are too long
+3486
-318
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+496
-338
File diff suppressed because one or more lines are too long
+2057
-337
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user