Closed
Description
It would be very handy if parts of the specification could be read by machines.
This would help developing SDKs for typed languages a lot, as many types can be auto generated.
Besides, there are some inconsistencies in non-normative parts of the specification that could be easily fixed (e.g. interfaces vs exported interfaces, params
vs param
).
Something like this would be awesome in addition to the existing specification:
(comments removed to keep it short)
interface RequestMessage<TMethod extends string, TParams> {
id: number | string;
method: TMethod;
params: TParams
}
interface ResponseMessage<TResult, TError> {
id: number | string;
result?: TResult;
error?: ResponseError<TError>;
}
interface Request<TRequest, TResponse> {}
interface Notification<TRequest> {}
// ...
type InitializeRequest = Request<
RequestMessage<"initialize", InitializeParams>,
ResponseMessage<InitializeResult, InitializeError>
>;
type ShutdownRequest = Request<
RequestMessage<"shutdown", undefined>,
ResponseMessage<undefined, undefined>
>;
type ShowMessageNotification = Notification<
RequestMessage<"window/showMessage", ShowMessageParams>
>;
What do you think? I can offer to add these additional typescript definitions for all of the about 30 notifications / requests.