Skip to content

Make specification more machine-readable #67

Closed
@hediet

Description

@hediet

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new features or functionalityhelp wantedIssues identified as good community contribution opportunities

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions