提交 fd4935de 编写于 作者: M Matt Bierner 提交者: GitHub

Handle typesInstallerInitializationFailed events (#23876)

* Handle typesInstallerInitializationFailed

Display a warning message when the ts typings installer fails to initilize. One possible cause is that npm is not installed

* Fix a spell
上级 84e3f399
......@@ -74,6 +74,7 @@ export interface ITypescriptServiceClient {
onProjectLanguageServiceStateChanged: Event<Proto.ProjectLanguageServiceStateEventBody>;
onDidBeginInstallTypings: Event<Proto.BeginInstallTypesEventBody>;
onDidEndInstallTypings: Event<Proto.EndInstallTypesEventBody>;
onTypesInstallerInitializationFailed: Event<Proto.TypesInstallerInitializationFailedEventBody>;
logTelemetry(eventName: string, properties?: { [prop: string]: string }): void;
......
......@@ -160,6 +160,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
private _onProjectLanguageServiceStateChanged = new EventEmitter<Proto.ProjectLanguageServiceStateEventBody>();
private _onDidBeginInstallTypings = new EventEmitter<Proto.BeginInstallTypesEventBody>();
private _onDidEndInstallTypings = new EventEmitter<Proto.EndInstallTypesEventBody>();
private _onTypesInstallerInitializationFailed = new EventEmitter<Proto.TypesInstallerInitializationFailedEventBody>();
private _packageInfo: IPackageInfo | null;
private _apiVersion: API;
......@@ -265,6 +266,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
return this._onDidEndInstallTypings.event;
}
get onTypesInstallerInitializationFailed(): Event<Proto.TypesInstallerInitializationFailedEventBody> {
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');
......
......@@ -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"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册