Skip to content

Generated typescript file is not usable anymore #834

@sherlock1982

Description

@sherlock1982

protobuf.js version: 6.8.0

Here's a part of my proto file:

message RequestUpdateDocument
{
        required ActionType Action = 1;
        optional WebMeetingDocument Document = 2;
        optional string Content = 3;
        optional int32 MeetingId = 4; 
}

Here's a part of generated typescript file using pbts:

        /** Properties of a RequestUpdateDocument. */
        interface IRequestUpdateDocument {

            /** RequestUpdateDocument Action */
            Action: MyPhone.Notifications.ActionType;

            /** RequestUpdateDocument Document */
            Document?: MyPhone.Notifications.IWebMeetingDocument;

            /** RequestUpdateDocument Content */
            Content?: string;

            /** RequestUpdateDocument MeetingId */
            MeetingId?: number;
        }

        /** Represents a RequestUpdateDocument. */
        class RequestUpdateDocument {

            /**
             * Constructs a new RequestUpdateDocument.
             * @param [properties] Properties to set
             */
            constructor(properties?: MyPhone.Notifications.IRequestUpdateDocument);

            /** RequestUpdateDocument Action. */
            public Action: MyPhone.Notifications.ActionType;

            /** RequestUpdateDocument Document. */
            public Document?: (MyPhone.Notifications.IWebMeetingDocument|null);

            /** RequestUpdateDocument Content. */
            public Content: string;

            /** RequestUpdateDocument MeetingId. */
            public MeetingId: number;
        }

You see that optional fields Document, Content, MeetingId have different types which makes this classes incompatible and this unusable. Class doesn't implement interface.

Expected behavior:

Interface and class should have same propeties. Probably it even makes sense to make class implement interface.

Also I don't understand why this:

properties?: MyPhone.Notifications.IRequestUpdateDocument

If we can make

properties?: Partial<MyPhone.Notifications.RequestUpdateDocument>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions