diff --git a/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts b/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts index bc06d18ee35..33845073e0b 100644 --- a/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts +++ b/extensions/typescript-language-features/src/tsServer/serverProcess.browser.ts @@ -3,10 +3,16 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import * as vscode from 'vscode'; +import * as nls from 'vscode-nls'; import type * as Proto from '../protocol'; import { TypeScriptServiceConfiguration } from '../utils/configuration'; +import { memoize } from '../utils/memoize'; import { TsServerProcess, TsServerProcessKind } from './server'; + +const localize = nls.loadMessageBundle(); + declare const Worker: any; declare type Worker = any; @@ -37,6 +43,11 @@ export class WorkerServerProcess implements TsServerProcess { args: readonly string[], ) { worker.addEventListener('message', (msg: any) => { + if (msg.data.type === 'log') { + this.output.appendLine(msg.data.body); + return; + } + for (const handler of this._onDataHandlers) { handler(msg.data); } @@ -44,6 +55,11 @@ export class WorkerServerProcess implements TsServerProcess { worker.postMessage(args); } + @memoize + private get output(): vscode.OutputChannel { + return vscode.window.createOutputChannel(localize('channelName', 'TypeScript Server Log')); + } + write(serverRequest: Proto.Request): void { this.worker.postMessage(serverRequest); }