Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
timostamm opened this issue Jan 17, 2025 · 0 comments
Open

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

timostamm opened this issue Jan 17, 2025 · 0 comments
Labels
Feature New feature or request

Comments

@timostamm
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant