Plain support of Nested Enums

This commit is contained in:
Mathieu Acthernoene 2017-01-10 11:40:48 +01:00
parent 66e9d20e1f
commit acbd1bf87b
3 changed files with 10 additions and 3 deletions

View File

@ -57,6 +57,10 @@ export type TestMessage = {|
r?: Array<number>;
u?: TestEnum;
v?: TestNestedEnum;
TestNestedMessage?: TestNestedMessage;

View File

@ -27,6 +27,7 @@ message TestMessage {
repeated int64 p = 16;
repeated float q = 17;
repeated double r = 18;
message TestNestedMessage {
string s = 1;
int32 t = 2;
@ -35,6 +36,9 @@ message TestMessage {
ELEMENT_C = 0;
ELEMENT_D = 1;
}
TestEnum u = 19;
TestNestedEnum v = 20;
}
message TestNoStreamRequest { TestMessage message = 1; }

View File

@ -148,7 +148,8 @@ func jsType(f *descriptor.FieldDescriptorProto) string {
}
switch *f.Type {
case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
case descriptor.FieldDescriptorProto_TYPE_MESSAGE,
descriptor.FieldDescriptorProto_TYPE_ENUM:
return fmt.Sprintf(template, shortType(*f.TypeName))
case descriptor.FieldDescriptorProto_TYPE_DOUBLE,
descriptor.FieldDescriptorProto_TYPE_FLOAT,
@ -169,8 +170,6 @@ func jsType(f *descriptor.FieldDescriptorProto) string {
return fmt.Sprintf(template, "Array<number>")
case descriptor.FieldDescriptorProto_TYPE_STRING:
return fmt.Sprintf(template, "string")
case descriptor.FieldDescriptorProto_TYPE_ENUM:
return fmt.Sprintf(template, "Object")
default:
return fmt.Sprintf(template, "any")
}