From 686ad172176f48eaef00d9e128d0fc0e999bbd52 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Mon, 27 Apr 2020 16:42:45 -0700 Subject: [PATCH] Clean up onTypesInstallerInitializationFailed - Convert to async - don't require using inline type with id --- .../src/utils/typingsStatus.ts | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/extensions/typescript-language-features/src/utils/typingsStatus.ts b/extensions/typescript-language-features/src/utils/typingsStatus.ts index a070b205621..6106fa812eb 100644 --- a/extensions/typescript-language-features/src/utils/typingsStatus.ts +++ b/extensions/typescript-language-features/src/utils/typingsStatus.ts @@ -96,32 +96,24 @@ export class AtaProgressReporter extends Disposable { } } - private onTypesInstallerInitializationFailed() { - interface MyMessageItem extends vscode.MessageItem { - id: number; - } + private async onTypesInstallerInitializationFailed() { + const config = vscode.workspace.getConfiguration('typescript'); - if (vscode.workspace.getConfiguration('typescript').get('check.npmIsInstalled', true)) { - vscode.window.showWarningMessage( + if (config.get('check.npmIsInstalled', true)) { + const dontShowAgain: vscode.MessageItem = { + title: localize('typesInstallerInitializationFailed.doNotCheckAgain', "Don't Show Again"), + }; + const selected = await vscode.window.showWarningMessage( localize( 'typesInstallerInitializationFailed.title', "Could not install typings files for JavaScript language features. Please ensure that NPM is installed or configure 'typescript.npm' in your user settings. Click [here]({0}) to learn more.", 'https://go.microsoft.com/fwlink/?linkid=847635' - ), { - title: localize('typesInstallerInitializationFailed.doNotCheckAgain', "Don't Show Again"), - id: 1 + ), + dontShowAgain); + + if (selected === dontShowAgain) { + config.update('check.npmIsInstalled', false, true); } - ).then(selected => { - if (!selected) { - return; - } - switch (selected.id) { - case 1: - const tsConfig = vscode.workspace.getConfiguration('typescript'); - tsConfig.update('check.npmIsInstalled', false, true); - break; - } - }); } } }