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

V2: Use suffix "Schema" for generated descriptors #890

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

timostamm
Copy link
Member

@timostamm timostamm commented Jun 13, 2024

When we generate code for a Protobuf message, we generate a TypeScript type for the instance shape, and a const for the message descriptor.

While it's possible to use the same identifier for both, the ambiguity isn't ideal. So far, we've been adding a "Desc" suffix to the name of the generated descriptor to differentiate:

syntax = "proto3";

message User {
  // ...
}

Generated:

export type User = ...

export const UserDesc = ...

// usage:
toBinary(UserDesc, user);

This PR changes the suffix of the descriptor to "Schema". It's a much more recognizable name:

export type User = ...

export const UserSchema = ...

// usage:
toBinary(UserSchema, user);

Related:

  • This change also applies to enum descriptors.
  • For file descriptors, their prefix is simplified from "fileDesc_" to "file_".
  • In @bufbuild/protoplugin, GeneratedFile.importDesc is renamed to importSchema.

@timostamm timostamm requested a review from srikrsna-buf June 13, 2024 15:54
@@ -28,14 +28,14 @@ async function main() {
}
const addressBookFile = process.argv[2];

const person = create(PersonDesc, {
const person = create(PersonSchema, {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems more understandable for users who aren't familiar with Protobuf descriptors.

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

Successfully merging this pull request may close these issues.

2 participants