commit
a0dec26d25
4 changed files with 10 additions and 10 deletions
|
@ -232,7 +232,7 @@ namespace ts.projectSystem {
|
||||||
return this.executeCommand(<T>request);
|
return this.executeCommand(<T>request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event<T>(body: T, eventName: string) {
|
public event<T extends object>(body: T, eventName: string) {
|
||||||
this.events.push(server.toEvent(eventName, body));
|
this.events.push(server.toEvent(eventName, body));
|
||||||
super.event(body, eventName);
|
super.event(body, eventName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,7 +502,7 @@ namespace ts.server {
|
||||||
constructor(options: IoSessionOptions) {
|
constructor(options: IoSessionOptions) {
|
||||||
const { host, eventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, canUseEvents } = options;
|
const { host, eventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, canUseEvents } = options;
|
||||||
|
|
||||||
const event: Event | undefined = (body: {}, eventName: string) => {
|
const event: Event | undefined = (body: object, eventName: string) => {
|
||||||
if (this.constructed) {
|
if (this.constructed) {
|
||||||
this.event(body, eventName);
|
this.event(body, eventName);
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,7 @@ namespace ts.server {
|
||||||
this.constructed = true;
|
this.constructed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
event<T>(body: T, eventName: string): void {
|
event<T extends object>(body: T, eventName: string): void {
|
||||||
Debug.assert(this.constructed, "Should only call `IOSession.prototype.event` on an initialized IOSession");
|
Debug.assert(this.constructed, "Should only call `IOSession.prototype.event` on an initialized IOSession");
|
||||||
|
|
||||||
if (this.canUseEvents && this.eventPort) {
|
if (this.canUseEvents && this.eventPort) {
|
||||||
|
@ -572,8 +572,8 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private writeToEventSocket(body: any, eventName: string): void {
|
private writeToEventSocket(body: object, eventName: string): void {
|
||||||
this.eventSocket.write(formatMessage(toEvent(body, eventName), this.logger, this.byteLength, this.host.newLine), "utf8");
|
this.eventSocket.write(formatMessage(toEvent(eventName, body), this.logger, this.byteLength, this.host.newLine), "utf8");
|
||||||
}
|
}
|
||||||
|
|
||||||
exit() {
|
exit() {
|
||||||
|
|
|
@ -239,14 +239,14 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Event = <T>(body: T, eventName: string) => void;
|
export type Event = <T extends object>(body: T, eventName: string) => void;
|
||||||
|
|
||||||
export interface EventSender {
|
export interface EventSender {
|
||||||
event: Event;
|
event: Event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function toEvent(eventName: string, body: {}): protocol.Event {
|
export function toEvent(eventName: string, body: object): protocol.Event {
|
||||||
return {
|
return {
|
||||||
seq: 0,
|
seq: 0,
|
||||||
type: "event",
|
type: "event",
|
||||||
|
@ -409,7 +409,7 @@ namespace ts.server {
|
||||||
this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine));
|
this.host.write(formatMessage(msg, this.logger, this.byteLength, this.host.newLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
public event<T>(body: T, eventName: string): void {
|
public event<T extends object>(body: T, eventName: string): void {
|
||||||
this.send(toEvent(eventName, body));
|
this.send(toEvent(eventName, body));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6930,7 +6930,7 @@ declare namespace ts.server {
|
||||||
type CommandNames = protocol.CommandTypes;
|
type CommandNames = protocol.CommandTypes;
|
||||||
const CommandNames: any;
|
const CommandNames: any;
|
||||||
function formatMessage<T extends protocol.Message>(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string;
|
function formatMessage<T extends protocol.Message>(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string;
|
||||||
type Event = <T>(body: T, eventName: string) => void;
|
type Event = <T extends object>(body: T, eventName: string) => void;
|
||||||
interface EventSender {
|
interface EventSender {
|
||||||
event: Event;
|
event: Event;
|
||||||
}
|
}
|
||||||
|
@ -6973,7 +6973,7 @@ declare namespace ts.server {
|
||||||
private projectsUpdatedInBackgroundEvent(openFiles);
|
private projectsUpdatedInBackgroundEvent(openFiles);
|
||||||
logError(err: Error, cmd: string): void;
|
logError(err: Error, cmd: string): void;
|
||||||
send(msg: protocol.Message): void;
|
send(msg: protocol.Message): void;
|
||||||
event<T>(body: T, eventName: string): void;
|
event<T extends object>(body: T, eventName: string): void;
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void;
|
output(info: any, cmdName: string, reqSeq?: number, errorMsg?: string): void;
|
||||||
private doOutput(info, cmdName, reqSeq, success, message?);
|
private doOutput(info, cmdName, reqSeq, success, message?);
|
||||||
|
|
Loading…
Reference in a new issue