Skip to content

Commit

Permalink
V2: Improve clash resolution in generated names (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Jun 13, 2024
1 parent cf191b1 commit 05acbc4
Show file tree
Hide file tree
Showing 7 changed files with 373 additions and 132 deletions.
2 changes: 1 addition & 1 deletion packages/bundle-size/src/protoc-gen-entrypoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ runNodeJs(
f.print("// ", file.file.proto.name);
for (const message of file.messages) {
const desc = f.import(
`${message.name}Desc`,
f.importDesc(message).name,
`./protobuf-es/${message.file.name}_pb.js`,
);
const createCall = [f.runtime.create, "(", desc, ")"];
Expand Down
17 changes: 11 additions & 6 deletions packages/protobuf-test/extra/name-clash.proto
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,21 @@ message BigInt {


message ClashParent {
// should clash with message ClashParent_ClashChild
message ClashChild {
}
// should clash with message ClashParent_ClashChild
message ClashChild {}
}

// TODO we do not support this case
// should clash with name of ClashParent.ClashChild
//message ClashParent_ClashChild {
//}
message ClashParent_ClashChild {
}

// message shape should clash with enum descriptor
message EnumDescClashWithMessageShapeDesc {}
enum EnumDescClashWithMessageShape { MessageDescClashWithEnumDescDesc_zero = 0; }

// enum shape should clash with message descriptor
enum EnumShapeClashWithMessageDescDesc { EnumShapeClashWithMessageDescDesc_zero = 0; }
message EnumShapeClashWithMessageDesc {}

message NoClashFields {
// ok as object property
Expand Down
124 changes: 98 additions & 26 deletions packages/protobuf-test/src/gen/js/extra/name-clash_pb.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 05acbc4

Please sign in to comment.