Skip to content

Commit

Permalink
Fix reference to worker session
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Nov 21, 2023
1 parent fbbdb79 commit af7e924
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 2 additions & 8 deletions extensions/typescript-language-features/web/src/webServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference lib='webworker.importscripts' />
/// <reference lib='webworker' />

import ts from 'typescript/lib/tsserverlibrary';
Expand All @@ -12,14 +11,10 @@ import { Logger, parseLogLevel } from './logging';
import { PathMapper } from './pathMapper';
import { createSys } from './serverHost';
import { findArgument, findArgumentStringArray, hasArgument, parseServerMode } from './util/args';
import { StartSessionOptions, createWorkerSession } from './workerSession';
import { StartSessionOptions, startWorkerSession } from './workerSession';

const setSys: (s: ts.System) => void = (ts as any).setSys;

// GLOBALS
let session: WorkerSession | undefined;
// END GLOBALS

async function initializeSession(
args: readonly string[],
extensionUri: URI,
Expand All @@ -46,8 +41,7 @@ async function initializeSession(
removeEventListener('message', listener);
});
setSys(sys);
session = createWorkerSession(ts, sys, fs, sessionOptions, ports.tsserver, pathMapper, logger);
session.listen();
startWorkerSession(ts, sys, fs, sessionOptions, ports.tsserver, pathMapper, logger);
}

function parseSessionOptions(args: readonly string[], serverMode: ts.LanguageServiceMode | undefined): StartSessionOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ export interface StartSessionOptions {
readonly disableAutomaticTypingAcquisition: boolean;
}

export function createWorkerSession(
export function startWorkerSession(
ts: typeof import('typescript/lib/tsserverlibrary'),
host: ts.server.ServerHost,
fs: FileSystem | undefined,
options: StartSessionOptions,
port: MessagePort,
pathMapper: PathMapper,
logger: Logger,
) {
): void {
const indent: (str: string) => string = (ts as any).server.indent;

return new class WorkerSession extends ts.server.Session<{}> {
const worker = new class WorkerSession extends ts.server.Session<{}> {

private readonly wasmCancellationToken: WasmCancellationToken;
private readonly listener: (message: any) => void;
Expand Down Expand Up @@ -121,4 +121,6 @@ export function createWorkerSession(
port.onmessage = this.listener;
}
}();

worker.listen();
}

0 comments on commit af7e924

Please sign in to comment.