Skip to content

Commit 081a08b

Browse files
reddalygonzojive
authored andcommitted
Fix treatment of nested messages.
Incorporates changes to protobuf-javascript library from gonzojive/protobuf-javascript#3.
1 parent 13729d9 commit 081a08b

File tree

3 files changed

+45
-24
lines changed

3 files changed

+45
-24
lines changed
Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,63 @@
11
syntax = "proto3";
22

3-
package com.example.greeting.v1;
3+
package com.example.greeting.v3;
44

55
import "github.com/gonzojive/rules_ts_proto/example/prefix/location/location.proto";
66

77
option java_multiple_files = true;
88

99
message GreetingRequest {
10-
string name = 1;
11-
.someorg.type.Position origin = 2;
12-
13-
message Greeting {
14-
string message = 1;
15-
}
16-
Greeting greeting_message = 3;
10+
string name = 1;
11+
.someorg.type.Position origin = 2;
12+
13+
message Greeting {
14+
int32 unimportant_field = 1;
15+
string message = 5;
16+
}
17+
Greeting greeting_message = 3;
1718
}
1819

1920
message GreetingResponse {
20-
string greeting = 1;
21+
string greeting = 1;
2122
}
2223

2324
service GreetingService {
24-
rpc greet(GreetingRequest) returns (GreetingResponse);
25+
rpc greet(GreetingRequest) returns (GreetingResponse);
2526
}
2627

2728
enum TopLevelEnumExample {
28-
EXAMPLE_ENUM_VALUE_1 = 0;
29-
THINGY2 = 2;
29+
EXAMPLE_ENUM_VALUE_1 = 0;
30+
THINGY2 = 2;
3031
}
3132

3233
message Foo {
33-
message Bar {}
34+
message Bar {}
3435
}
3536

3637
message RepeatedThing {
37-
repeated string child_strings = 1;
38+
repeated string child_strings = 1;
3839

39-
repeated .someorg.type.Position child_positions = 2;
40+
repeated .someorg.type.Position child_positions = 2;
4041

41-
repeated GreetingRequest child_requests = 3;
42-
repeated TopLevelEnumExample child_enums = 4;
43-
repeated Foo.Bar child_bars = 5;
42+
repeated GreetingRequest child_requests = 3;
43+
repeated TopLevelEnumExample child_enums = 4;
44+
repeated Foo.Bar child_bars = 5;
4445
}
4546

4647
message MutuallyExclusiveThing {
47-
oneof some_value {
48-
string mutex_string = 1;
49-
.someorg.type.Position mutex_position = 2;
48+
oneof some_value {
49+
string mutex_string = 1;
50+
.someorg.type.Position mutex_position = 2;
51+
}
52+
}
53+
54+
message Ancestor1 {
55+
message Ancestor2 {
56+
message Ancestor3 {
57+
int32 ignored1 = 1;
58+
int32 ignored2 = 2;
59+
int32 ignored3 = 3;
60+
string value = 4;
5061
}
51-
}
62+
}
63+
}

e2e/typescript_proto_usage/tests/greeting_jasmine/greeting.spec.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GreetingRequest, TopLevelEnumExample, RepeatedThing } from "../../greeting_pb.mjs"
1+
import { Ancestor1, GreetingRequest, TopLevelEnumExample, RepeatedThing } from "../../greeting_pb.mjs"
22
import { Position } from "../../location/location_pb.mjs"
33
//import { GreetingRequest } from "../../greeting_pb";
44

@@ -28,6 +28,15 @@ describe("lib", () => {
2828
expect(requestRoundtripped.getGreetingMessage().getMessage()).toBe(message);
2929
});
3030

31+
it("sub-sub types should be serializable", () => {
32+
const input = new Ancestor1.Ancestor2.Ancestor3()
33+
.setValue("xyz");
34+
const inputRoundtripped = Ancestor1.Ancestor2.Ancestor3.deserializeBinary(
35+
input.serializeBinary());
36+
expect(input.getValue()).toBe("xyz");
37+
expect(inputRoundtripped.getValue()).toBe("xyz");
38+
});
39+
3140
it("should be serializable with repeated fields", () => {
3241
const object = new RepeatedThing().setChildStringsList(["x", "y"]);
3342
const roundtripped = RepeatedThing.deserializeBinary(object.serializeBinary());

ts_proto/repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def rules_ts_proto_dependencies():
4545

4646
git_repository(
4747
name = "com_google_protobuf_javascript",
48-
commit = "dfa5a70a44926f183bdf4fd001dcca869a4f4ad6",
48+
commit = "d3ce92c081bd585dc6079609a868744b5e3033fe",
4949
remote = "https://github.com/gonzojive/protobuf-javascript.git",
5050
)
5151

0 commit comments

Comments
 (0)