diff --git a/extensions/typescript/src/typescriptService.ts b/extensions/typescript/src/typescriptService.ts index 289c227daf34c929369a46de82fe9150d018ee0d..5edfa590f2a4dbb16e69a260b83f6f8686bdf002 100644 --- a/extensions/typescript/src/typescriptService.ts +++ b/extensions/typescript/src/typescriptService.ts @@ -74,6 +74,7 @@ export interface ITypescriptServiceClient { onProjectLanguageServiceStateChanged: Event; onDidBeginInstallTypings: Event; onDidEndInstallTypings: Event; + onTypesInstallerInitializationFailed: Event; logTelemetry(eventName: string, properties?: { [prop: string]: string }): void; diff --git a/extensions/typescript/src/typescriptServiceClient.ts b/extensions/typescript/src/typescriptServiceClient.ts index 7c1bb4385d188362c29ba99b18933b2529edb42d..fef0d1cdf48c3ea3c6e1e4b29a159a11e0ca50c1 100644 --- a/extensions/typescript/src/typescriptServiceClient.ts +++ b/extensions/typescript/src/typescriptServiceClient.ts @@ -160,6 +160,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient private _onProjectLanguageServiceStateChanged = new EventEmitter(); private _onDidBeginInstallTypings = new EventEmitter(); private _onDidEndInstallTypings = new EventEmitter(); + private _onTypesInstallerInitializationFailed = new EventEmitter(); private _packageInfo: IPackageInfo | null; private _apiVersion: API; @@ -265,6 +266,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient return this._onDidEndInstallTypings.event; } + get onTypesInstallerInitializationFailed(): Event { + return this._onTypesInstallerInitializationFailed.event; + } + private get output(): OutputChannel { if (!this._output) { this._output = window.createOutputChannel(localize('channelName', 'TypeScript')); @@ -1017,6 +1022,11 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient if (data) { this._onDidEndInstallTypings.fire(data); } + } else if (event.event === 'typesInstallerInitializationFailed') { + const data = (event as Proto.TypesInstallerInitializationFailedEvent).body; + if (data) { + this._onTypesInstallerInitializationFailed.fire(data); + } } } else { throw new Error('Unknown message type ' + message.type + ' recevied'); diff --git a/extensions/typescript/src/utils/typingsStatus.ts b/extensions/typescript/src/utils/typingsStatus.ts index de5cd9d291e359c916b0cf4f093013187d00aead..6e7a98751feb3d4a8169505afabcf9175b175110 100644 --- a/extensions/typescript/src/utils/typingsStatus.ts +++ b/extensions/typescript/src/utils/typingsStatus.ts @@ -68,8 +68,8 @@ export class AtaProgressReporter { constructor(client: ITypescriptServiceClient) { this._disposable = vscode.Disposable.from( client.onDidBeginInstallTypings(e => this._onBegin(e.eventId)), - client.onDidEndInstallTypings(e => this._onEndOrTimeout(e.eventId)) - ); + client.onDidEndInstallTypings(e => this._onEndOrTimeout(e.eventId)), + client.onTypesInstallerInitializationFailed(_ => this.onTypesInstallerInitializationFailed())); } dispose(): void { @@ -96,4 +96,8 @@ export class AtaProgressReporter { resolve(); } } + + private onTypesInstallerInitializationFailed() { + vscode.window.showWarningMessage(localize('typesInstallerInitializationFailed', "Could not install typings files for JS/TS language features. Please ensure that NPM is installed")); + } }