Skip to content

Commit a02cfa5

Browse files
committed
fix: debugging ts no launch config fails if tsc task detection off
Fixes microsoft/vscode#69572
1 parent 6d447f3 commit a02cfa5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/ui/configuration/nodeDebugConfigurationResolver.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export function createLaunchConfigFromContext(
338338

339339
let dir = '';
340340
const tsConfig = loadJSON<ITSConfig>(folder, 'tsconfig.json');
341-
if (tsConfig && tsConfig.compilerOptions && tsConfig.compilerOptions.outDir) {
341+
if (tsConfig?.compilerOptions?.outDir && canDetectTsBuildTask()) {
342342
const outDir = tsConfig.compilerOptions.outDir;
343343
if (!path.isAbsolute(outDir)) {
344344
dir = outDir;
@@ -357,6 +357,11 @@ export function createLaunchConfigFromContext(
357357
return config;
358358
}
359359

360+
function canDetectTsBuildTask() {
361+
const value = vscode.workspace.getConfiguration().get('typescript.tsc.autoDetect');
362+
return value !== 'off' && value !== 'watch';
363+
}
364+
360365
function configureMern(config: ResolvingNodeConfiguration) {
361366
if (config.request !== 'launch') {
362367
return;
@@ -374,7 +379,7 @@ function isTranspiledLanguage(languagId: string): boolean {
374379
return languagId === 'typescript' || languagId === 'coffeescript';
375380
}
376381

377-
function loadJSON<T>(folder: vscode.WorkspaceFolder | undefined, file: string): T | void {
382+
function loadJSON<T>(folder: vscode.WorkspaceFolder | undefined, file: string): T | undefined {
378383
if (folder) {
379384
try {
380385
const content = fs.readFileSync(path.join(folder.uri.fsPath, file), 'utf8');

0 commit comments

Comments
 (0)