Skip to content

Provide a strong type name in the generated message schema #1056

Open
@timostamm

Description

From #994 (comment):

It would be very convenient to include a strongly typed type name in the schema for a generated message. For example:

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

This definition generates a type User and a const UserSchema. The type's $typeName property is strongly typed, but the schema's typeName property is not:

const user: User = create(UserSchema);
user.$typeName; // "example.User"

UserSchema.typeName; // string

This means the schema's property cannot be used to construct an instance of the type, and it cannot be used to narrow down a message by using the property as a descriminator.

If it's possible without breaking changes, we should change the generated schema to support this.

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

    FeatureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions