diff --git a/extensions/typescript-language-features/src/features/task.ts b/extensions/typescript-language-features/src/features/task.ts index e3e48bdb500..b63ff25019f 100644 --- a/extensions/typescript-language-features/src/features/task.ts +++ b/extensions/typescript-language-features/src/features/task.ts @@ -74,29 +74,29 @@ export default class TscTaskProvider implements vscode.TaskProvider { public async resolveTask(task: vscode.Task): Promise { const definition = task.definition; - const badTsconfig = /\\tsconfig.*\.json/; - if (badTsconfig.test(definition.tsconfig)) { + if (/\\tsconfig.*\.json/.test(definition.tsconfig)) { // Warn that the task has the wrong slash type vscode.window.showWarningMessage(localize('badTsConfig', "TypeScript Task in tasks.json contains \"\\\\\". TypeScript tasks tsconfig must use \"/\"")); return undefined; } - const typescriptTask = definition.tsconfig; - if (typescriptTask) { - if (task.scope === undefined || task.scope === vscode.TaskScope.Global || task.scope === vscode.TaskScope.Workspace) { - // scope is required to be a WorkspaceFolder for resolveTask - return undefined; - } - const tsconfigUri: vscode.Uri = task.scope.uri.with({ path: task.scope.uri.path + '/' + definition.tsconfig }); - const tsconfig: TSConfig = { - uri: tsconfigUri, - fsPath: tsconfigUri.fsPath, - posixPath: tsconfigUri.path, - workspaceFolder: task.scope - }; - return this.getTasksForProjectAndDefinition(tsconfig, definition); + const tsconfigPath = definition.tsconfig; + if (!tsconfigPath) { + return undefined; } - return undefined; + + if (task.scope === undefined || task.scope === vscode.TaskScope.Global || task.scope === vscode.TaskScope.Workspace) { + // scope is required to be a WorkspaceFolder for resolveTask + return undefined; + } + const tsconfigUri = task.scope.uri.with({ path: task.scope.uri.path + '/' + tsconfigPath }); + const tsconfig: TSConfig = { + uri: tsconfigUri, + fsPath: tsconfigUri.fsPath, + posixPath: tsconfigUri.path, + workspaceFolder: task.scope + }; + return this.getTasksForProjectAndDefinition(tsconfig, definition); } private async getAllTsConfigs(token: vscode.CancellationToken): Promise {