mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
Add setting to disable NPM Not installed error (#25112)
Adds a new setting to disable the npm not installed warning that we show when ATA fails Fixes #25063
This commit is contained in:
@@ -7,17 +7,18 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { MessageItem, workspace, Disposable, window, commands } from 'vscode';
|
||||
import { ITypescriptServiceClient } from '../typescriptService';
|
||||
import { loadMessageBundle } from 'vscode-nls';
|
||||
|
||||
const localize = loadMessageBundle();
|
||||
|
||||
const typingsInstallTimeout = 30 * 1000;
|
||||
|
||||
export default class TypingsStatus extends vscode.Disposable {
|
||||
export default class TypingsStatus extends Disposable {
|
||||
private _acquiringTypings: { [eventId: string]: NodeJS.Timer } = Object.create({});
|
||||
private _client: ITypescriptServiceClient;
|
||||
private _subscriptions: vscode.Disposable[] = [];
|
||||
private _subscriptions: Disposable[] = [];
|
||||
|
||||
constructor(client: ITypescriptServiceClient) {
|
||||
super(() => this.dispose());
|
||||
@@ -63,10 +64,10 @@ export default class TypingsStatus extends vscode.Disposable {
|
||||
export class AtaProgressReporter {
|
||||
|
||||
private _promises = new Map<number, Function>();
|
||||
private _disposable: vscode.Disposable;
|
||||
private _disposable: Disposable;
|
||||
|
||||
constructor(client: ITypescriptServiceClient) {
|
||||
this._disposable = vscode.Disposable.from(
|
||||
this._disposable = Disposable.from(
|
||||
client.onDidBeginInstallTypings(e => this._onBegin(e.eventId)),
|
||||
client.onDidEndInstallTypings(e => this._onEndOrTimeout(e.eventId)),
|
||||
client.onTypesInstallerInitializationFailed(_ => this.onTypesInstallerInitializationFailed()));
|
||||
@@ -86,7 +87,7 @@ export class AtaProgressReporter {
|
||||
});
|
||||
});
|
||||
|
||||
vscode.window.withWindowProgress(localize('installingPackages', "Fetching data for better TypeScript IntelliSense"), () => promise);
|
||||
window.withWindowProgress(localize('installingPackages', "Fetching data for better TypeScript IntelliSense"), () => promise);
|
||||
}
|
||||
|
||||
private _onEndOrTimeout(eventId: number): void {
|
||||
@@ -98,6 +99,42 @@ export class AtaProgressReporter {
|
||||
}
|
||||
|
||||
private onTypesInstallerInitializationFailed() {
|
||||
vscode.window.showWarningMessage(localize('typesInstallerInitializationFailed', "Could not install typings files for JS/TS language features. Please ensure that NPM is installed"));
|
||||
interface MyMessageItem extends MessageItem {
|
||||
id: number;
|
||||
}
|
||||
|
||||
if (workspace.getConfiguration('typescript').get<boolean>('check.npmIsInstalled', true)) {
|
||||
window.showWarningMessage<MyMessageItem>(
|
||||
localize(
|
||||
'typesInstallerInitializationFailed.title',
|
||||
"Could not install typings files for JavaScript language features. Please ensure that NPM is installed"
|
||||
), {
|
||||
title: localize('typesInstallerInitializationFailed.moreInformation', "More Information"),
|
||||
id: 1
|
||||
},
|
||||
{
|
||||
title: localize('typesInstallerInitializationFailed.doNotCheckAgain', "Don't Check Again"),
|
||||
id: 2
|
||||
},
|
||||
{
|
||||
title: localize('typesInstallerInitializationFailed.close', 'Close'),
|
||||
id: 3,
|
||||
isCloseAffordance: true
|
||||
}
|
||||
).then(selected => {
|
||||
if (!selected || selected.id === 3) {
|
||||
return;
|
||||
}
|
||||
switch (selected.id) {
|
||||
case 1:
|
||||
commands.executeCommand('open', 'https://go.microsoft.com/fwlink/?linkid=847635');
|
||||
break;
|
||||
case 2:
|
||||
const tsConfig = workspace.getConfiguration('typescript');
|
||||
tsConfig.update('check.npmIsInstalled', false, true);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user