diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index cb968d0138b..cbcae0ce83f 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -1547,6 +1547,10 @@ declare namespace ts.server.protocol { * true if install request succeeded, otherwise - false */ installSuccess: boolean; + /** + * version of typings installer + */ + typingsInstallerVersion: string; } interface NavBarResponse extends Response { body?: NavigationBarItem[]; diff --git a/lib/tsc.js b/lib/tsc.js index 662a7f2bc49..fa635d2ea07 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -123,6 +123,10 @@ var ts; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); var ts; +(function (ts) { + ts.version = "2.0.10"; +})(ts || (ts = {})); +var ts; (function (ts) { var createObject = Object.create; ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; @@ -37138,7 +37142,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.0.9"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } diff --git a/lib/tsserver.js b/lib/tsserver.js index 9d57b342d34..4e581524abf 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -128,6 +128,10 @@ var ts; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); var ts; +(function (ts) { + ts.version = "2.0.10"; +})(ts || (ts = {})); +var ts; (function (ts) { var createObject = Object.create; ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; @@ -38553,7 +38557,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.0.9"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -56347,7 +56350,8 @@ var ts; telemetryEventName: "typingsInstalled", payload: { installedPackages: response.packagesToInstall.join(","), - installSuccess: response.installSuccess + installSuccess: response.installSuccess, + typingsInstallerVersion: response.typingsInstallerVersion } }; var eventName = "telemetry"; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 4ea77e69fdd..e1160ddb706 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -664,6 +664,7 @@ declare namespace ts.server.protocol { interface TypingsInstalledTelemetryEventPayload { installedPackages: string; installSuccess: boolean; + typingsInstallerVersion: string; } interface NavBarResponse extends Response { body?: NavigationBarItem[]; @@ -2930,6 +2931,9 @@ declare namespace ts.performance { function enable(): void; function disable(): void; } +declare namespace ts { + const version: string; +} declare namespace ts { const enum Ternary { False = 0, @@ -8258,7 +8262,6 @@ declare namespace ts { function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult; } declare namespace ts { - const version: string; function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 597d5236af5..3cff8ec5e68 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -128,6 +128,10 @@ var ts; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); var ts; +(function (ts) { + ts.version = "2.0.10"; +})(ts || (ts = {})); +var ts; (function (ts) { var createObject = Object.create; ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; @@ -38553,7 +38557,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.0.9"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 39d6b7421c8..7c2d5744fd1 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -1758,6 +1758,10 @@ declare namespace ts { _children: Node[]; } } +declare namespace ts { + /** The version of the TypeScript compiler release */ + const version: string; +} declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -1897,8 +1901,6 @@ declare namespace ts { function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { - /** The version of the TypeScript compiler release */ - const version: string; function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; /** diff --git a/lib/typescript.js b/lib/typescript.js index 6e73e1ab4da..0bd58928c89 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -1004,6 +1004,11 @@ var ts; })(ts || (ts = {})); /// /// +var ts; +(function (ts) { + /** The version of the TypeScript compiler release */ + ts.version = "2.0.10"; +})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -1694,7 +1699,7 @@ var ts; return 1 /* GreaterThan */; if (ignoreCase) { if (ts.collator && String.prototype.localeCompare) { - // accent means a ≠ b, a ≠ á, a = A + // accent means a ? b, a ? a´, a = A var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } @@ -44687,7 +44692,6 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.0.9"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 2a99204dffa..ceb50a5d6d5 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -1758,6 +1758,10 @@ declare namespace ts { _children: Node[]; } } +declare namespace ts { + /** The version of the TypeScript compiler release */ + const version: string; +} declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; type DirectoryWatcherCallback = (fileName: string) => void; @@ -1897,8 +1901,6 @@ declare namespace ts { function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { - /** The version of the TypeScript compiler release */ - const version: string; function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string; function resolveTripleslashReference(moduleName: string, containingFile: string): string; /** diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 6e73e1ab4da..0bd58928c89 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -1004,6 +1004,11 @@ var ts; })(ts || (ts = {})); /// /// +var ts; +(function (ts) { + /** The version of the TypeScript compiler release */ + ts.version = "2.0.10"; +})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -1694,7 +1699,7 @@ var ts; return 1 /* GreaterThan */; if (ignoreCase) { if (ts.collator && String.prototype.localeCompare) { - // accent means a ≠ b, a ≠ á, a = A + // accent means a ? b, a ? a´, a = A var result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" }); return result < 0 ? -1 /* LessThan */ : result > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; } @@ -44687,7 +44692,6 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.0.9"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 6df9fd24e74..a200ac5367d 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -128,6 +128,10 @@ var ts; })(performance = ts.performance || (ts.performance = {})); })(ts || (ts = {})); var ts; +(function (ts) { + ts.version = "2.0.10"; +})(ts || (ts = {})); +var ts; (function (ts) { var createObject = Object.create; ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; @@ -5725,9 +5729,17 @@ var ts; isEnabled: function () { return false; }, writeLine: function () { } }; - function typingToFileName(cachePath, packageName, installTypingHost) { - var result = ts.resolveModuleName(packageName, ts.combinePaths(cachePath, "index.d.ts"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, installTypingHost); - return result.resolvedModule && result.resolvedModule.resolvedFileName; + function typingToFileName(cachePath, packageName, installTypingHost, log) { + try { + var result = ts.resolveModuleName(packageName, ts.combinePaths(cachePath, "index.d.ts"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, installTypingHost); + return result.resolvedModule && result.resolvedModule.resolvedFileName; + } + catch (e) { + if (log.isEnabled()) { + log.writeLine("Failed to resolve " + packageName + " in folder '" + cachePath + "': " + e.message); + } + return undefined; + } } (function (PackageNameValidationResult) { PackageNameValidationResult[PackageNameValidationResult["Ok"] = 0] = "Ok"; @@ -5853,8 +5865,9 @@ var ts; if (!packageName) { continue; } - var typingFile = typingToFileName(cacheLocation, packageName, this.installTypingHost); + var typingFile = typingToFileName(cacheLocation, packageName, this.installTypingHost, this.log); if (!typingFile) { + this.missingTypingsSet[packageName] = true; continue; } var existingTypingFile = this.packageNameToTypingLocation[packageName]; @@ -5885,7 +5898,7 @@ var ts; var result = []; for (var _i = 0, typingsToInstall_1 = typingsToInstall; _i < typingsToInstall_1.length; _i++) { var typing = typingsToInstall_1[_i]; - if (this.missingTypingsSet[typing]) { + if (this.missingTypingsSet[typing] || this.packageNameToTypingLocation[typing]) { continue; } var validationResult = validatePackageName(typing); @@ -5958,7 +5971,8 @@ var ts; _this.sendResponse({ kind: server.EventInstall, packagesToInstall: scopedTypings, - installSuccess: ok + installSuccess: ok, + typingsInstallerVersion: ts.version }); } if (!ok) { @@ -5972,17 +5986,14 @@ var ts; return; } if (_this.log.isEnabled()) { - _this.log.writeLine("Requested to install typings " + JSON.stringify(scopedTypings) + ", installed typings " + JSON.stringify(scopedTypings)); + _this.log.writeLine("Installed typings " + JSON.stringify(scopedTypings)); } var installedTypingFiles = []; - for (var _a = 0, scopedTypings_1 = scopedTypings; _a < scopedTypings_1.length; _a++) { - var t = scopedTypings_1[_a]; - var packageName = ts.getBaseFileName(t); - if (!packageName) { - continue; - } - var typingFile = typingToFileName(cachePath, packageName, _this.installTypingHost); + for (var _a = 0, filteredTypings_2 = filteredTypings; _a < filteredTypings_2.length; _a++) { + var packageName = filteredTypings_2[_a]; + var typingFile = typingToFileName(cachePath, packageName, _this.installTypingHost, _this.log); if (!typingFile) { + _this.missingTypingsSet[packageName] = true; continue; } if (!_this.packageNameToTypingLocation[packageName]) { @@ -6121,14 +6132,13 @@ var ts; this.log.writeLine("Process id: " + process.pid); } this.npmPath = getNPMLocation(process.argv[0]); - var execSync; - (_a = require("child_process"), this.exec = _a.exec, execSync = _a.execSync, _a); + (_a = require("child_process"), this.execSync = _a.execSync, _a); this.ensurePackageDirectoryExists(globalTypingsCacheLocation); try { if (this.log.isEnabled()) { this.log.writeLine("Updating " + TypesRegistryPackageName + " npm package..."); } - execSync(this.npmPath + " install " + TypesRegistryPackageName, { cwd: globalTypingsCacheLocation, stdio: "ignore" }); + this.execSync(this.npmPath + " install " + TypesRegistryPackageName, { cwd: globalTypingsCacheLocation, stdio: "ignore" }); } catch (e) { if (this.log.isEnabled()) { @@ -6160,18 +6170,26 @@ var ts; } }; NodeTypingsInstaller.prototype.installWorker = function (requestId, args, cwd, onRequestCompleted) { - var _this = this; if (this.log.isEnabled()) { this.log.writeLine("#" + requestId + " with arguments'" + JSON.stringify(args) + "'."); } var command = this.npmPath + " install " + args.join(" ") + " --save-dev"; var start = Date.now(); - this.exec(command, { cwd: cwd }, function (err, stdout, stderr) { - if (_this.log.isEnabled()) { - _this.log.writeLine("npm install #" + requestId + " took: " + (Date.now() - start) + " ms" + ts.sys.newLine + "stdout: " + stdout + ts.sys.newLine + "stderr: " + stderr); - } - onRequestCompleted(!err); - }); + var stdout; + var stderr; + var hasError = false; + try { + stdout = this.execSync(command, { cwd: cwd }); + } + catch (e) { + stdout = e.stdout; + stderr = e.stderr; + hasError = true; + } + if (this.log.isEnabled()) { + this.log.writeLine("npm install #" + requestId + " took: " + (Date.now() - start) + " ms" + ts.sys.newLine + "stdout: " + (stdout && stdout.toString()) + ts.sys.newLine + "stderr: " + (stderr && stderr.toString())); + } + onRequestCompleted(!hasError); }; return NodeTypingsInstaller; }(typingsInstaller.TypingsInstaller));