Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 52e867c

Browse filesBrowse files
authored
Merge pull request microsoft#16277 from minestarks/safelistpackagenames
discoverTypings should look at typingSafelist.json values
2 parents 0600a27 + ba04dc8 commit 52e867c
Copy full SHA for 52e867c

3 files changed

+28-7Lines changed: 28 additions & 7 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/harness/unittests/tsserverProjectSystem.ts‎

Copy file name to clipboardExpand all lines: src/harness/unittests/tsserverProjectSystem.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ namespace ts.projectSystem {
1313
express: "express",
1414
jquery: "jquery",
1515
lodash: "lodash",
16-
moment: "moment"
16+
moment: "moment",
17+
chroma: "chroma-js"
1718
})
1819
};
1920

@@ -61,7 +62,6 @@ namespace ts.projectSystem {
6162
super(installTypingHost, globalTypingsCacheLocation, safeList.path, throttleLimit, log);
6263
}
6364

64-
safeFileList = safeList.path;
6565
protected postExecActions: PostExecAction[] = [];
6666

6767
executePendingCommands() {
Collapse file

‎src/harness/unittests/typingsInstaller.ts‎

Copy file name to clipboardExpand all lines: src/harness/unittests/typingsInstaller.ts
+24-3Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,13 +1009,34 @@ namespace ts.projectSystem {
10091009
});
10101010

10111011
describe("discover typings", () => {
1012+
it("should use mappings from safe list", () => {
1013+
const app = {
1014+
path: "/a/b/app.js",
1015+
content: ""
1016+
};
1017+
const jquery = {
1018+
path: "/a/b/jquery.js",
1019+
content: ""
1020+
};
1021+
const chroma = {
1022+
path: "/a/b/chroma.min.js",
1023+
content: ""
1024+
};
1025+
const cache = createMap<string>();
1026+
1027+
const host = createServerHost([app, jquery, chroma]);
1028+
const result = JsTyping.discoverTypings(host, [app.path, jquery.path, chroma.path], getDirectoryPath(<Path>app.path), /*safeListPath*/ undefined, cache, { enable: true }, []);
1029+
assert.deepEqual(result.newTypingNames, ["jquery", "chroma-js"]);
1030+
});
1031+
10121032
it("should return node for core modules", () => {
10131033
const f = {
10141034
path: "/a/b/app.js",
10151035
content: ""
10161036
};
10171037
const host = createServerHost([f]);
10181038
const cache = createMap<string>();
1039+
10191040
for (const name of JsTyping.nodeCoreModuleList) {
10201041
const result = JsTyping.discoverTypings(host, [f.path], getDirectoryPath(<Path>f.path), /*safeListPath*/ undefined, cache, { enable: true }, [name, "somename"]);
10211042
assert.deepEqual(result.newTypingNames.sort(), ["node", "somename"]);
@@ -1040,7 +1061,7 @@ namespace ts.projectSystem {
10401061
});
10411062

10421063
describe("telemetry events", () => {
1043-
it ("should be received", () => {
1064+
it("should be received", () => {
10441065
const f1 = {
10451066
path: "/a/app.js",
10461067
content: ""
@@ -1089,7 +1110,7 @@ namespace ts.projectSystem {
10891110
});
10901111

10911112
describe("progress notifications", () => {
1092-
it ("should be sent for success", () => {
1113+
it("should be sent for success", () => {
10931114
const f1 = {
10941115
path: "/a/app.js",
10951116
content: ""
@@ -1140,7 +1161,7 @@ namespace ts.projectSystem {
11401161
checkProjectActualFiles(projectService.inferredProjects[0], [f1.path, commander.path]);
11411162
});
11421163

1143-
it ("should be sent for error", () => {
1164+
it("should be sent for error", () => {
11441165
const f1 = {
11451166
path: "/a/app.js",
11461167
content: ""
Collapse file

‎src/services/jsTyping.ts‎

Copy file name to clipboardExpand all lines: src/services/jsTyping.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace ts.JsTyping {
143143
/**
144144
* Merge a given list of typingNames to the inferredTypings map
145145
*/
146-
function mergeTypings(typingNames: string[]) {
146+
function mergeTypings(typingNames: ReadonlyArray<string>) {
147147
if (!typingNames) {
148148
return;
149149
}
@@ -192,7 +192,7 @@ namespace ts.JsTyping {
192192
const cleanedTypingNames = map(inferredTypingNames, f => f.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""));
193193

194194
if (safeList !== EmptySafeList) {
195-
mergeTypings(filter(cleanedTypingNames, f => safeList.has(f)));
195+
mergeTypings(ts.mapDefined(cleanedTypingNames, f => safeList.get(f)));
196196
}
197197

198198
const hasJsxFile = forEach(fileNames, f => ensureScriptKind(f, getScriptKindFromFileName(f)) === ScriptKind.JSX);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.