Skip to content

Commit 6846ea3

Browse files
authored
added extra check to prevent multiple installation of the same typing, added version field to telemetry event (#12258)
* added extra check to prevent multiple installation of the same typing, added version field to telemetry event * use ts.version
1 parent 0a3afb5 commit 6846ea3

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

src/compiler/core.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
/* @internal */
55
namespace ts {
6+
7+
export const version = "2.0.9";
8+
69
/**
710
* Ternary values are defined such that
811
* x & y is False if either x or y is False.

src/compiler/program.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
namespace ts {
66
/** The version of the TypeScript compiler release */
77

8-
export const version = "2.0.9";
9-
108
const emptyArray: any[] = [];
119

1210
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string {

src/server/protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,6 +1968,11 @@ namespace ts.server.protocol {
19681968
* true if install request succeeded, otherwise - false
19691969
*/
19701970
installSuccess: boolean;
1971+
1972+
/**
1973+
* version of typings installer
1974+
*/
1975+
typingsInstallerVersion: string;
19711976
}
19721977

19731978
export interface NavBarResponse extends Response {

src/server/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ namespace ts.server {
266266
telemetryEventName: "typingsInstalled",
267267
payload: {
268268
installedPackages: response.packagesToInstall.join(","),
269-
installSuccess: response.installSuccess
269+
installSuccess: response.installSuccess,
270+
typingsInstallerVersion: response.typingsInstallerVersion
270271
}
271272
};
272273
const eventName: protocol.TelemetryEventName = "telemetry";

src/server/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ declare namespace ts.server {
6363
readonly packagesToInstall: ReadonlyArray<string>;
6464
readonly kind: EventInstall;
6565
readonly installSuccess: boolean;
66+
readonly typingsInstallerVersion: string;
6667
}
6768

6869
export interface InstallTypingHost extends JsTyping.TypingResolutionHost {

src/server/typingsInstaller/typingsInstaller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ namespace ts.server.typingsInstaller {
230230
}
231231
const result: string[] = [];
232232
for (const typing of typingsToInstall) {
233-
if (this.missingTypingsSet[typing]) {
233+
if (this.missingTypingsSet[typing] || this.packageNameToTypingLocation[typing]) {
234234
continue;
235235
}
236236
const validationResult = validatePackageName(typing);
@@ -308,7 +308,8 @@ namespace ts.server.typingsInstaller {
308308
this.sendResponse(<TypingsInstallEvent>{
309309
kind: EventInstall,
310310
packagesToInstall: scopedTypings,
311-
installSuccess: ok
311+
installSuccess: ok,
312+
typingsInstallerVersion: ts.version // qualified explicitly to prevent occasional shadowing
312313
});
313314
}
314315

0 commit comments

Comments
 (0)