Skip to content

Commit a69adf2

Browse files
committed
Run test in both module resolvers
1 parent 1e66f07 commit a69adf2

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

src/harness/unittests/tsserverProjectSystem.ts

+49-3
Original file line numberDiff line numberDiff line change
@@ -6045,8 +6045,8 @@ namespace ts.projectSystem {
60456045
});
60466046
});
60476047

6048-
describe("Subfolder invalidations correctly include parent folder failed lookup locations QJWOP", () => {
6049-
it("Includes the parent folder FLLs", () => {
6048+
describe("Subfolder invalidations correctly include parent folder failed lookup locations", () => {
6049+
function runFailedLookupTest(resolution: "Node" | "Classic") {
60506050
const projectLocation = "/proj";
60516051
const file1: FileOrFolder = {
60526052
path: `${projectLocation}/foo/boo/app.ts`,
@@ -6059,7 +6059,8 @@ namespace ts.projectSystem {
60596059
const tsconfig: FileOrFolder = {
60606060
path: `${projectLocation}/tsconfig.json`,
60616061
content: JSON.stringify({
6062-
files: ["foo/boo/app.ts", "foo/boo/moo/app.ts"]
6062+
files: ["foo/boo/app.ts", "foo/boo/moo/app.ts"],
6063+
moduleResolution: resolution
60636064
})
60646065
};
60656066

@@ -6083,6 +6084,13 @@ namespace ts.projectSystem {
60836084
checkProjectActualFiles(project, files.map(f => f.path));
60846085
assert.deepEqual(project.getLanguageService().getSemanticDiagnostics(file1.path).map(diag => diag.messageText), []);
60856086
assert.deepEqual(project.getLanguageService().getSemanticDiagnostics(file2.path).map(diag => diag.messageText), []);
6087+
}
6088+
6089+
it("Includes the parent folder FLLs in node module resolution mode", () => {
6090+
runFailedLookupTest("Node");
6091+
});
6092+
it("Includes the parent folder FLLs in classic module resolution mode", () => {
6093+
runFailedLookupTest("Classic");
60866094
});
60876095
});
60886096

@@ -6252,6 +6260,44 @@ namespace ts.projectSystem {
62526260
verifyNpmInstall(/*timeoutDuringPartialInstallation*/ false);
62536261
});
62546262
});
6263+
6264+
it("when node_modules dont receive event for the @types file addition", () => {
6265+
const projectLocation = "/user/username/folder/myproject";
6266+
const app: FileOrFolder = {
6267+
path: `${projectLocation}/app.ts`,
6268+
content: `import * as debug from "debug"`
6269+
};
6270+
const tsconfig: FileOrFolder = {
6271+
path: `${projectLocation}/tsconfig.json`,
6272+
content: ""
6273+
};
6274+
6275+
const files = [app, tsconfig, libFile];
6276+
const host = createServerHost(files);
6277+
const service = createProjectService(host);
6278+
service.openClientFile(app.path);
6279+
6280+
const project = service.configuredProjects.get(tsconfig.path);
6281+
checkProjectActualFiles(project, files.map(f => f.path));
6282+
assert.deepEqual(project.getLanguageService().getSemanticDiagnostics(app.path).map(diag => diag.messageText), ["Cannot find module 'debug'."]);
6283+
6284+
const debugTypesFile: FileOrFolder = {
6285+
path: `${projectLocation}/node_modules/@types/debug/index.d.ts`,
6286+
content: "export {}"
6287+
};
6288+
files.push(debugTypesFile);
6289+
// Do not invoke recursive directory watcher for anything other than node_module/@types
6290+
const invoker = host.invokeWatchedDirectoriesRecursiveCallback;
6291+
host.invokeWatchedDirectoriesRecursiveCallback = (fullPath, relativePath) => {
6292+
if (fullPath.endsWith("@types")) {
6293+
invoker.call(host, fullPath, relativePath);
6294+
}
6295+
};
6296+
host.reloadFS(files);
6297+
host.runQueuedTimeoutCallbacks();
6298+
checkProjectActualFiles(project, files.map(f => f.path));
6299+
assert.deepEqual(project.getLanguageService().getSemanticDiagnostics(app.path).map(diag => diag.messageText), []);
6300+
});
62556301
});
62566302

62576303
describe("tsserverProjectSystem ProjectsChangedInBackground", () => {

0 commit comments

Comments
 (0)