Permalink
Browse files

Breaking: Everything uses interfaces now instead of typedefs (Somethi…

…ngProperties is now ISomething)
  • Loading branch information...
dcodeIO committed Apr 15, 2017
1 parent 5bc3541 commit c97b61811248df002f1fb93557b982bc0aa27309
@@ -1,3 +1,4 @@
**/node_modules/*
bin/*
cli/wrappers/*
coverage/*
@@ -311,7 +311,10 @@ function writeInterface(element) {
function writeInterfaceBody(element) {
writeln("{");
++indent;
element.properties.forEach(writeProperty);
if (element.tsType)
writeln(element.tsType);
else if (element.properties && element.properties.length)
element.properties.forEach(writeProperty);
--indent;
write("}");
}
@@ -429,6 +432,9 @@ function handleClass(element, parent) {
writeln("{");
++indent;
if (element.tsType)
writeln(element.tsType);
// constructor
if (!is_interface && !element.virtual)
handleFunction(element, parent, true);

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -4,7 +4,8 @@
"array-type": [ true, "array" ],
"no-namespace": false,
"interface-name": [ false ],
"interface-over-type-literal": false,
"interface-over-type-literal": true,
"no-empty-interface": false,
"max-line-length": [ false ],
"trailing-comma": [ true, "never" ],
"variable-name": [ false ],
@@ -34,39 +34,39 @@ API
The extension adds `.fromDescriptor(descriptor[, syntax])` and `#toDescriptor([syntax])` methods to reflection objects and exports the `.google.protobuf` namespace of the internally used `Root` instance containing the following types present in descriptor.proto:
| Descriptor type | protobuf.js type | Remarks
|--------------------------------|------------------|---------
| **FileDescriptorSet** | Root |
| FileDescriptorProto | | dependencies are not supported
| FileOptions | |
| FileOptions_OptimizeMode | |
| SourceCodeInfo | | not supported
| SourceCodeInfo_Location | |
| GeneratedCodeInfo | | not supported
| GeneratedCodeInfo_Annotation | |
| **DescriptorProto** | Type |
| MessageOptions | |
| DescriptorProto_ExtensionRange | |
| DescriptorProto_ReservedRange | |
| **FieldDescriptorProto** | Field |
| FieldDescriptorProto_Label | |
| FieldDescriptorProto_Type | |
| FieldOptions | |
| FieldOptions_CType | |
| FieldOptions_JSType | |
| **OneofDescriptorProto** | OneOf |
| OneofOptions | |
| **EnumDescriptorProto** | Enum |
| EnumOptions | |
| EnumValueDescriptorProto | |
| EnumValueOptions | | not supported
| **ServiceDescriptorProto** | Service |
| ServiceOptions | |
| **MethodDescriptorProto** | Method |
| MethodOptions | |
| UninterpretedOption | | not supported
| UninterpretedOption_NamePart | |
| Descriptor type | protobuf.js type | Remarks
|-------------------------------|------------------|---------
| **FileDescriptorSet** | Root |
| FileDescriptorProto | | dependencies are not supported
| FileOptions | |
| FileOptionsOptimizeMode | |
| SourceCodeInfo | | not supported
| SourceCodeInfoLocation | |
| GeneratedCodeInfo | | not supported
| GeneratedCodeInfoAnnotation | |
| **DescriptorProto** | Type |
| MessageOptions | |
| DescriptorProtoExtensionRange | |
| DescriptorProtoReservedRange | |
| **FieldDescriptorProto** | Field |
| FieldDescriptorProtoLabel | |
| FieldDescriptorProtoType | |
| FieldOptions | |
| FieldOptionsCType | |
| FieldOptionsJSType | |
| **OneofDescriptorProto** | OneOf |
| OneofOptions | |
| **EnumDescriptorProto** | Enum |
| EnumOptions | |
| EnumValueDescriptorProto | |
| EnumValueOptions | | not supported
| **ServiceDescriptorProto** | Service |
| ServiceOptions | |
| **MethodDescriptorProto** | Method |
| MethodOptions | |
| UninterpretedOption | | not supported
| UninterpretedOptionNamePart | |
Note that not all features of descriptor.proto translate perfectly to a protobuf.js root instance. A root instance has only limited knowlege of packages or individual files for example, which is then compensated by guessing and generating fictional file names.
When using TypeScript, the respective `...$Properties` types can be used to reference specific message types (i.e. `protobuf.Message<DescriptorProto$Properties>`).
When using TypeScript, the respective interface types can be used to reference specific message instances (i.e. `protobuf.Message<IDescriptorProto>`).
@@ -1,31 +1,31 @@
import * as $protobuf from "../..";
type FileDescriptorSet$Properties = {
file: FileDescriptorProto$Properties[];
};
export interface IFileDescriptorSet {
file: IFileDescriptorProto[];
}
type FileDescriptorProto$Properties = {
export interface IFileDescriptorProto {
name?: string;
package?: string;
dependency?: any;
publicDependency?: any;
weakDependency?: any;
messageType?: DescriptorProto$Properties[];
enumType?: EnumDescriptorProto$Properties[];
service?: ServiceDescriptorProto$Properties[];
extension?: FieldDescriptorProto$Properties[];
options?: FileOptions$Properties;
messageType?: IDescriptorProto[];
enumType?: IEnumDescriptorProto[];
service?: IServiceDescriptorProto[];
extension?: IFieldDescriptorProto[];
options?: IFileOptions;
sourceCodeInfo?: any;
syntax?: string;
};
}
type FileOptions$Properties = {
export interface IFileOptions {
javaPackage?: string;
javaOuterClassname?: string;
javaMultipleFiles?: boolean;
javaGenerateEqualsAndHash?: boolean;
javaStringCheckUtf8?: boolean;
optimizeFor?: FileOptions$OptimizeMode;
optimizeFor?: IFileOptionsOptimizeMode;
goPackage?: string;
ccGenericServices?: boolean;
javaGenericServices?: boolean;
@@ -34,121 +34,121 @@ type FileOptions$Properties = {
ccEnableArenas?: boolean;
objcClassPrefix?: string;
csharpNamespace?: string;
};
}
type FileOptions$OptimizeMode = number;
type IFileOptionsOptimizeMode = number;
type DescriptorProto$Properties = {
export interface IDescriptorProto {
name?: string;
field?: FieldDescriptorProto$Properties[];
extension?: FieldDescriptorProto$Properties[];
nestedType?: DescriptorProto$Properties[];
enumType?: EnumDescriptorProto$Properties[];
extensionRange?: ExtensionRange$Properties[];
oneofDecl?: OneofDescriptorProto$Properties[];
options?: MessageOptions$Properties;
reservedRange?: ReservedRange$Properties[];
field?: IFieldDescriptorProto[];
extension?: IFieldDescriptorProto[];
nestedType?: IDescriptorProto[];
enumType?: IEnumDescriptorProto[];
extensionRange?: IDescriptorProtoExtensionRange[];
oneofDecl?: IOneofDescriptorProto[];
options?: IMessageOptions;
reservedRange?: IDescriptorProtoReservedRange[];
reservedName?: string[];
};
}
type MessageOptions$Properties = {
export interface IMessageOptions {
mapEntry?: boolean;
};
}
type ExtensionRange$Properties = {
export interface IDescriptorProtoExtensionRange {
start?: number;
end?: number;
};
}
type ReservedRange$Properties = {
export interface IDescriptorProtoReservedRange {
start?: number;
end?: number;
};
}
type FieldDescriptorProto$Properties = {
export interface IFieldDescriptorProto {
name?: string;
number?: number;
label?: FieldDescriptorProto$Label;
type?: FieldDescriptorProto$Type;
label?: IFieldDescriptorProtoLabel;
type?: IFieldDescriptorProtoType;
typeName?: string;
extendee?: string;
defaultValue?: string;
oneofIndex?: number;
jsonName?: any;
options?: FieldOptions$Properties;
};
options?: IFieldOptionsProperties;
}
type FieldDescriptorProto$Label = number;
type IFieldDescriptorProtoLabel = number;
type FieldDescriptorProto$Type = number;
type IFieldDescriptorProtoType = number;
type FieldOptions$Properties = {
export interface IFieldOptions {
packed?: boolean;
jstype?: FieldOptions$JSType;
};
jstype?: IFieldOptionsJSType;
}
type FieldOptions$JSType = number;
type IFieldOptionsJSType = number;
type EnumDescriptorProto$Properties = {
export interface IEnumDescriptorProto {
name?: string;
value?: EnumValueDescriptorProto$Properties[];
options?: EnumOptions$Properties;
};
value?: IEnumValueDescriptorProto[];
options?: IEnumOptions;
}
type EnumValueDescriptorProto$Properties = {
export interface IEnumValueDescriptorProto {
name?: string;
number?: number;
options?: any;
};
}
type EnumOptions$Properties = {
export interface IEnumOptions {
allowAlias?: boolean;
deprecated?: boolean;
};
}
type OneofDescriptorProto$Properties = {
export interface IOneofDescriptorProto {
name?: string;
options?: any;
};
}
type ServiceDescriptorProto$Properties = {
export interface IServiceDescriptorProto {
name?: string;
method?: MethodDescriptorProto$Properties[];
options?: ServiceOptions$Properties;
};
method?: IMethodDescriptorProto[];
options?: IServiceOptions;
}
type ServiceOptions$Properties = {
export interface IServiceOptions {
deprecated?: boolean;
};
}
type MethodDescriptorProto$Properties = {
export interface IMethodDescriptorProto {
name?: string;
inputType?: string;
outputType?: string;
options?: MethodOptions$Properties;
options?: IMethodOptions;
clientStreaming?: boolean;
serverStreaming?: boolean;
};
}
type MethodOptions$Properties = {
export interface IMethodOptions {
deprecated?: boolean;
};
}
export const FileDescriptorSet: $protobuf.Type;
export const FileDescriptorProto: $protobuf.Type;
export const DescriptorProto: $protobuf.Type;
export const DescriptorProto_ExtensionRange: $protobuf.Type;
export const DescriptorProtoExtensionRange: $protobuf.Type;
export const DescriptorProto_ReservedRange: $protobuf.Type;
export const DescriptorProtoReservedRange: $protobuf.Type;
export const FieldDescriptorProto: $protobuf.Type;
export const FieldDescriptorProto_Label: $protobuf.Enum;
export const FieldDescriptorProtoLabel: $protobuf.Enum;
export const FieldDescriptorProto_Type: $protobuf.Enum;
export const FieldDescriptorProtoType: $protobuf.Enum;
export const OneofDescriptorProto: $protobuf.Type;
@@ -162,15 +162,15 @@ export const MethodDescriptorProto: $protobuf.Type;
export const FileOptions: $protobuf.Type;
export const FileOptions_OptimizeMode: $protobuf.Enum;
export const FileOptionsOptimizeMode: $protobuf.Enum;
export const MessageOptions: $protobuf.Type;
export const FieldOptions: $protobuf.Type;
export const FieldOptions_CType: $protobuf.Enum;
export const FieldOptionsCType: $protobuf.Enum;
export const FieldOptions_JSType: $protobuf.Enum;
export const FieldOptionsJSType: $protobuf.Enum;
export const OneofOptions: $protobuf.Type;
@@ -184,12 +184,12 @@ export const MethodOptions: $protobuf.Type;
export const UninterpretedOption: $protobuf.Type;
export const UninterpretedOption_NamePart: $protobuf.Type;
export const UninterpretedOptionNamePart: $protobuf.Type;
export const SourceCodeInfo: $protobuf.Type;
export const SourceCodeInfo_Location: $protobuf.Type;
export const SourceCodeInfoLocation: $protobuf.Type;
export const GeneratedCodeInfo: $protobuf.Type;
export const GeneratedCodeInfo_Annotation: $protobuf.Type;
export const GeneratedCodeInfoAnnotation: $protobuf.Type;
Oops, something went wrong.

0 comments on commit c97b618

Please sign in to comment.