diff --git a/extensions/typescript/src/typescriptServiceClient.ts b/extensions/typescript/src/typescriptServiceClient.ts index a36818b3905..595d56d117f 100644 --- a/extensions/typescript/src/typescriptServiceClient.ts +++ b/extensions/typescript/src/typescriptServiceClient.ts @@ -354,8 +354,9 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient return this.servicePromise = new Promise(async (resolve, reject) => { try { const tsServerForkArgs = await this.getTsServerArgs(currentVersion); + const debugPort = this.getDebugPort(); const tsServerForkOptions: electron.IForkOptions = { - execArgv: [] // [`--debug-brk=5859`] + execArgv: debugPort ? [`--inspect=${debugPort}`] : [] // [`--debug-brk=5859`] }; electron.fork(currentVersion.tsServerPath, tsServerForkArgs, tsServerForkOptions, this.logger, (err: any, childProcess: cp.ChildProcess | null) => { if (err || !childProcess) { @@ -942,6 +943,18 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient return args; } + + private getDebugPort(): number | undefined { + const value = process.env['TSS_DEBUG']; + if (value) { + const port = parseInt(value); + if (!isNaN(port)) { + return port; + } + } + return undefined; + } + private resetClientVersion() { this._apiVersion = API.defaultVersion; this._tsserverVersion = undefined;