From c3651027bac025df1d9e4c07898228f9f419e04b Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 18 Sep 2020 16:23:49 -0700 Subject: [PATCH] Use enum --- .../src/task/taskProvider.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/extensions/typescript-language-features/src/task/taskProvider.ts b/extensions/typescript-language-features/src/task/taskProvider.ts index 588722af268..aa2fd99325f 100644 --- a/extensions/typescript-language-features/src/task/taskProvider.ts +++ b/extensions/typescript-language-features/src/task/taskProvider.ts @@ -17,7 +17,12 @@ import { TSConfig, TsConfigProvider } from './tsconfigProvider'; const localize = nls.loadMessageBundle(); -type AutoDetect = 'on' | 'off' | 'build' | 'watch'; +enum AutoDetect { + on = 'on', + off = 'off', + build = 'build', + watch = 'watch' +} const exists = async (resource: vscode.Uri): Promise => { try { @@ -42,7 +47,7 @@ class TscTaskProvider implements vscode.TaskProvider { private readonly projectInfoRequestTimeout = 2000; private readonly findConfigFilesTimeout = 5000; - private autoDetect: AutoDetect = 'on'; + private autoDetect = AutoDetect.on; private readonly tsconfigProvider: TsConfigProvider; private readonly disposables: vscode.Disposable[] = []; @@ -61,7 +66,7 @@ class TscTaskProvider implements vscode.TaskProvider { public async provideTasks(token: vscode.CancellationToken): Promise { const folders = vscode.workspace.workspaceFolders; - if ((this.autoDetect === 'off') || !folders || !folders.length) { + if ((this.autoDetect === AutoDetect.off) || !folders || !folders.length) { return []; } @@ -245,11 +250,11 @@ class TscTaskProvider implements vscode.TaskProvider { const tasks: vscode.Task[] = []; - if (this.autoDetect === 'build' || this.autoDetect === 'on') { + if (this.autoDetect === AutoDetect.build || this.autoDetect === AutoDetect.on) { tasks.push(this.getBuildTask(project.workspaceFolder, label, command, args, { type: 'typescript', tsconfig: label })); } - if (this.autoDetect === 'watch' || this.autoDetect === 'on') { + if (this.autoDetect === AutoDetect.watch || this.autoDetect === AutoDetect.on) { tasks.push(this.getWatchTask(project.workspaceFolder, label, command, args, { type: 'typescript', tsconfig: label, option: 'watch' })); } @@ -298,7 +303,7 @@ class TscTaskProvider implements vscode.TaskProvider { private onConfigurationChanged(): void { const type = vscode.workspace.getConfiguration('typescript.tsc').get('autoDetect'); - this.autoDetect = typeof type === 'undefined' ? 'on' : type; + this.autoDetect = typeof type === 'undefined' ? AutoDetect.on : type; } }