Skip to content

Create raw data types as well #1058

Open
@abalmos

Description

syntax = "proto3";
package example;
message User {
  string id = 1;
}

will produce something like

export type User = Message<"example.User"> & {
  /**
   * @generated from field: string id = 1;
   */
  id: string;
}

However, the User type is hard to use when working with the message body as data throughout the code based because of the $typeName and $unknown fileds that Message<"example.User"> adds. What if instead it generated something like:

export type UserRaw = {
  /**
   * @generated from field: string id = 1;
   */
  id: string;
};

export type User = Message<"example.User"> & UserRaw

So that UserRaw can be used to hold data in the program logic, but one can also easily do:

const user: UserRaw = { id: "123" };
create(UserSchema, user)

This would remove the need for using a helper like OmitTypeName all over the place.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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