/// /// import EventEmitter from 'node:events'; import type { ChildProcess } from 'node:child_process'; import type { server as tsserver } from 'typescript'; /** * This class provides a wrapper around a process running tsserver and is used to communicate * with the server, mainly to support diagnostics for user code (type errors, sytnax errors, * type definitions, etc). * * tsserver is not documented. Here is a brief overview. * * tsserver is a process which listens for messages over stdin and * sends messages over stdout. tsserver has three types of messages: * * 1. Request: A request from the client to the server. * 2. Response: A response from the server to a specific client request. * 3. Event: An event from the server to the client. * * Request and responses are identified a unique number called `seq`. `seq` is incremented * for each request the client sends. The client will send a `seq` field with its request * and the server will provide a `request_seq` in its response which is used to tie a message * from the server to a specific request from the client. * * Events can arrive at any time but are often used as an asynchronous response from the server. * For example, syntax and semantic diagnostics are sent as events when using the `geterr` command. * * Most of this is learned by reading through the source (protocol.ts) as well as trial * and error. They also have an introduction, but it's hardly useful. See links below. * * - https://github.com/microsoft/TypeScript/blob/v5.5.3/src/server/protocol.ts * - https://github.com/microsoft/TypeScript/wiki/Standalone-Server-(tsserver) */ export declare class TsServer extends EventEmitter { private _seq; private buffered; private readonly process; private readonly resolvers; constructor(process: ChildProcess); private get seq(); private handleResponse; private handleEvent; private send; private sendWithResponsePromise; /** * Wrapper around the `semanticDiag` event for convenience and type safety. */ onSemanticDiag(callback: (event: tsserver.protocol.DiagnosticEvent) => void): void; /** * Wrapper around the `syntaxDiag` event for convenience and type safety. */ onSyntaxDiag(callback: (event: tsserver.protocol.DiagnosticEvent) => void): void; /** * Wrapper around the `suggestionDiag` event for convenience and type safety. */ onSuggestionDiag(callback: (event: tsserver.protocol.DiagnosticEvent) => void): void; /** * Shutdown the underlying tsserver process. */ shutdown(): boolean; /** * Explicitly 'open' a file in tsserver. * * This is used to tell tsserver to start tracking a file and all its dependencies. */ open(args: tsserver.protocol.OpenRequestArgs): void; /** * Explicitly 'close' a file in tsserver. * * This is used to tell tsserver to stop tracking a file. */ close(args: tsserver.protocol.FileRequestArgs): void; /** * Ask tsserver to send diagnostics for a set of files. * * This is used to get the errors for a set of files in a project. * * Note that the diagnostics are sent as asynchronous events instead of responding to this request. */ geterr(args: tsserver.protocol.GeterrRequestArgs): void; /** * Reload the project in tsserver. * * This is used to tell tsserver to reload the project configuration * which helps ensure that the project is up-to-date. This helps resolve * errors that can occur when renaming files. */ reloadProjects(): void; /** * Get info about the project. * * This can be useful during development to inspect the tsserver integration. */ projectInfo(args: tsserver.protocol.ProjectInfoRequestArgs): Promise; /** * Get info about a term at a specific location in a file. * * This is used for type definitions and documentation lookups on hover. */ quickinfo(args: tsserver.protocol.FileLocationRequestArgs): Promise; } //# sourceMappingURL=tsserver.d.mts.map