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>; r?: Array<number>;
u?: TestEnum;
v?: TestNestedEnum;
TestNestedMessage?: TestNestedMessage; TestNestedMessage?: TestNestedMessage;

View File

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

View File

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