Merge pull request #19542 from RyanCavanaugh/fix19533

Exclude legacy safelist files in external projects
This commit is contained in:
Ryan Cavanaugh
2017-11-10 15:28:35 -08:00
committed by GitHub
6 changed files with 89 additions and 17 deletions
@@ -1539,6 +1539,42 @@ namespace ts.projectSystem {
}
});
it("removes version numbers correctly", () => {
const testData: [string, string][] = [
["jquery-max", "jquery-max"],
["jquery.min", "jquery"],
["jquery-min.4.2.3", "jquery"],
["jquery.min.4.2.1", "jquery"],
["minimum", "minimum"],
["min", "min"],
["min.3.2", "min"],
["jquery", "jquery"]
];
for (const t of testData) {
assert.equal(removeMinAndVersionNumbers(t[0]), t[1], t[0]);
}
});
it("ignores files excluded by a legacy safe type list", () => {
const file1 = {
path: "/a/b/bliss.js",
content: "let x = 5"
};
const file2 = {
path: "/a/b/foo.js",
content: ""
};
const host = createServerHost([file1, file2, customTypesMap]);
const projectService = createProjectService(host);
try {
projectService.openExternalProject({ projectFileName: "project", options: {}, rootFiles: toExternalFiles([file1.path, file2.path]), typeAcquisition: { enable: true } });
const proj = projectService.externalProjects[0];
assert.deepEqual(proj.getFileNames(), [file2.path]);
} finally {
projectService.resetSafeList();
}
});
it("open file become a part of configured project if it is referenced from root file", () => {
const file1 = {
path: "/a/b/f1.ts",
+3 -2
View File
@@ -1057,11 +1057,12 @@ namespace ts.projectSystem {
const host = createServerHost([app, jquery, chroma]);
const logger = trackingLogger();
const result = JsTyping.discoverTypings(host, logger.log, [app.path, jquery.path, chroma.path], getDirectoryPath(<Path>app.path), safeList, emptyMap, { enable: true }, emptyArray);
assert.deepEqual(logger.finish(), [
const finish = logger.finish();
assert.deepEqual(finish, [
'Inferred typings from file names: ["jquery","chroma-js"]',
"Inferred typings from unresolved imports: []",
'Result: {"cachedTypingPaths":[],"newTypingNames":["jquery","chroma-js"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}',
]);
], finish.join("\r\n"));
assert.deepEqual(result.newTypingNames, ["jquery", "chroma-js"]);
});