-
Notifications
You must be signed in to change notification settings - Fork 75
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
Name the plain type which actually matches the protobuf definition #1060
base: main
Are you sure you want to change the base?
Conversation
The type was already generated but not exported (except as a union export). Having access to this plain type is almost essential for application code that utilizes the generated message types for purposes beyond this library's own API. Signed-off-by: Andrew Balmos <[email protected]>
|
I think the issue here is that Example: syntax = "proto3";
import "google/protobuf/timestamp.proto";
message Pet {
string name = 1;
PetType pet_type = 2;
}
message PetType {
oneof type {
Cat cat = 1;
Dog dog = 2;
}
}
message Cat {
string breed = 1;
}
message Dog {
string breed = 1;
} Generates: // @generated by protoc-gen-es v2.2.3 with parameter "json_types=true"
// @generated from file com/clearme/protobuf/Pet.proto (syntax proto3)
/* eslint-disable */
import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv1";
import type { Message } from "@bufbuild/protobuf";
/**
* Describes the file com/clearme/protobuf/Pet.proto.
*/
export declare const file_com_clearme_protobuf_Pet: GenFile;
/**
* @generated from message Pet
*/
export declare type Pet = Message<"Pet"> & {
/**
* @generated from field: string name = 1;
*/
name: string;
/**
* @generated from field: PetType pet_type = 2;
*/
petType?: PetType;
};
/**
* @generated from message Pet
*/
export declare type PetJson = {
/**
* @generated from field: string name = 1;
*/
name?: string;
/**
* @generated from field: PetType pet_type = 2;
*/
petType?: PetTypeJson;
};
/**
* Describes the message Pet.
* Use `create(PetSchema)` to create a new message.
*/
export declare const PetSchema: GenMessage<Pet, PetJson>;
/**
* @generated from message PetType
*/
export declare type PetType = Message<"PetType"> & {
/**
* @generated from oneof PetType.type
*/
type: {
/**
* @generated from field: Cat cat = 1;
*/
value: Cat;
case: "cat";
} | {
/**
* @generated from field: Dog dog = 2;
*/
value: Dog;
case: "dog";
} | { case: undefined; value?: undefined };
};
/**
* @generated from message PetType
*/
export declare type PetTypeJson = {
/**
* @generated from field: Cat cat = 1;
*/
cat?: CatJson;
/**
* @generated from field: Dog dog = 2;
*/
dog?: DogJson;
};
/**
* Describes the message PetType.
* Use `create(PetTypeSchema)` to create a new message.
*/
export declare const PetTypeSchema: GenMessage<PetType, PetTypeJson>;
/**
* @generated from message Cat
*/
export declare type Cat = Message<"Cat"> & {
/**
* @generated from field: string breed = 1;
*/
breed: string;
};
/**
* @generated from message Cat
*/
export declare type CatJson = {
/**
* @generated from field: string breed = 1;
*/
breed?: string;
};
/**
* Describes the message Cat.
* Use `create(CatSchema)` to create a new message.
*/
export declare const CatSchema: GenMessage<Cat, CatJson>;
/**
* @generated from message Dog
*/
export declare type Dog = Message<"Dog"> & {
/**
* @generated from field: string breed = 1;
*/
breed: string;
};
/**
* @generated from message Dog
*/
export declare type DogJson = {
/**
* @generated from field: string breed = 1;
*/
breed?: string;
};
/**
* Describes the message Dog.
* Use `create(DogSchema)` to create a new message.
*/
export declare const DogSchema: GenMessage<Dog, DogJson>; I am aiming to get something very similar here: #1062. My suggestion is to add an option to make the OR Should |
The type was already generated, but not exported (except as a union export). Having access to this plain type is almost essential for application code that utilizes the generated message types for purposes beyond this library's own API.
fixes #1058