Skip to content

Commit c97b618

Browse files
committed
Breaking: Everything uses interfaces now instead of typedefs (SomethingProperties is now ISomething)
1 parent 5bc3541 commit c97b618

37 files changed

+2333
-1891
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
**/node_modules/*
12
bin/*
23
cli/wrappers/*
34
coverage/*

cli/lib/tsd-jsdoc/publish.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ function writeInterface(element) {
311311
function writeInterfaceBody(element) {
312312
writeln("{");
313313
++indent;
314-
element.properties.forEach(writeProperty);
314+
if (element.tsType)
315+
writeln(element.tsType);
316+
else if (element.properties && element.properties.length)
317+
element.properties.forEach(writeProperty);
315318
--indent;
316319
write("}");
317320
}
@@ -429,6 +432,9 @@ function handleClass(element, parent) {
429432
writeln("{");
430433
++indent;
431434

435+
if (element.tsType)
436+
writeln(element.tsType);
437+
432438
// constructor
433439
if (!is_interface && !element.virtual)
434440
handleFunction(element, parent, true);

cli/targets/static.js

+64-65
Large diffs are not rendered by default.

config/tslint.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"array-type": [ true, "array" ],
55
"no-namespace": false,
66
"interface-name": [ false ],
7-
"interface-over-type-literal": false,
7+
"interface-over-type-literal": true,
8+
"no-empty-interface": false,
89
"max-line-length": [ false ],
910
"trailing-comma": [ true, "never" ],
1011
"variable-name": [ false ],

ext/descriptor/README.md

+33-33
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,39 @@ API
3434

3535
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:
3636

37-
| Descriptor type | protobuf.js type | Remarks
38-
|--------------------------------|------------------|---------
39-
| **FileDescriptorSet** | Root |
40-
| FileDescriptorProto | | dependencies are not supported
41-
| FileOptions | |
42-
| FileOptions_OptimizeMode | |
43-
| SourceCodeInfo | | not supported
44-
| SourceCodeInfo_Location | |
45-
| GeneratedCodeInfo | | not supported
46-
| GeneratedCodeInfo_Annotation | |
47-
| **DescriptorProto** | Type |
48-
| MessageOptions | |
49-
| DescriptorProto_ExtensionRange | |
50-
| DescriptorProto_ReservedRange | |
51-
| **FieldDescriptorProto** | Field |
52-
| FieldDescriptorProto_Label | |
53-
| FieldDescriptorProto_Type | |
54-
| FieldOptions | |
55-
| FieldOptions_CType | |
56-
| FieldOptions_JSType | |
57-
| **OneofDescriptorProto** | OneOf |
58-
| OneofOptions | |
59-
| **EnumDescriptorProto** | Enum |
60-
| EnumOptions | |
61-
| EnumValueDescriptorProto | |
62-
| EnumValueOptions | | not supported
63-
| **ServiceDescriptorProto** | Service |
64-
| ServiceOptions | |
65-
| **MethodDescriptorProto** | Method |
66-
| MethodOptions | |
67-
| UninterpretedOption | | not supported
68-
| UninterpretedOption_NamePart | |
37+
| Descriptor type | protobuf.js type | Remarks
38+
|-------------------------------|------------------|---------
39+
| **FileDescriptorSet** | Root |
40+
| FileDescriptorProto | | dependencies are not supported
41+
| FileOptions | |
42+
| FileOptionsOptimizeMode | |
43+
| SourceCodeInfo | | not supported
44+
| SourceCodeInfoLocation | |
45+
| GeneratedCodeInfo | | not supported
46+
| GeneratedCodeInfoAnnotation | |
47+
| **DescriptorProto** | Type |
48+
| MessageOptions | |
49+
| DescriptorProtoExtensionRange | |
50+
| DescriptorProtoReservedRange | |
51+
| **FieldDescriptorProto** | Field |
52+
| FieldDescriptorProtoLabel | |
53+
| FieldDescriptorProtoType | |
54+
| FieldOptions | |
55+
| FieldOptionsCType | |
56+
| FieldOptionsJSType | |
57+
| **OneofDescriptorProto** | OneOf |
58+
| OneofOptions | |
59+
| **EnumDescriptorProto** | Enum |
60+
| EnumOptions | |
61+
| EnumValueDescriptorProto | |
62+
| EnumValueOptions | | not supported
63+
| **ServiceDescriptorProto** | Service |
64+
| ServiceOptions | |
65+
| **MethodDescriptorProto** | Method |
66+
| MethodOptions | |
67+
| UninterpretedOption | | not supported
68+
| UninterpretedOptionNamePart | |
6969

7070
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.
7171

72-
When using TypeScript, the respective `...$Properties` types can be used to reference specific message types (i.e. `protobuf.Message<DescriptorProto$Properties>`).
72+
When using TypeScript, the respective interface types can be used to reference specific message instances (i.e. `protobuf.Message<IDescriptorProto>`).

ext/descriptor/index.d.ts

+72-72
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import * as $protobuf from "../..";
22

3-
type FileDescriptorSet$Properties = {
4-
file: FileDescriptorProto$Properties[];
5-
};
3+
export interface IFileDescriptorSet {
4+
file: IFileDescriptorProto[];
5+
}
66

7-
type FileDescriptorProto$Properties = {
7+
export interface IFileDescriptorProto {
88
name?: string;
99
package?: string;
1010
dependency?: any;
1111
publicDependency?: any;
1212
weakDependency?: any;
13-
messageType?: DescriptorProto$Properties[];
14-
enumType?: EnumDescriptorProto$Properties[];
15-
service?: ServiceDescriptorProto$Properties[];
16-
extension?: FieldDescriptorProto$Properties[];
17-
options?: FileOptions$Properties;
13+
messageType?: IDescriptorProto[];
14+
enumType?: IEnumDescriptorProto[];
15+
service?: IServiceDescriptorProto[];
16+
extension?: IFieldDescriptorProto[];
17+
options?: IFileOptions;
1818
sourceCodeInfo?: any;
1919
syntax?: string;
20-
};
20+
}
2121

22-
type FileOptions$Properties = {
22+
export interface IFileOptions {
2323
javaPackage?: string;
2424
javaOuterClassname?: string;
2525
javaMultipleFiles?: boolean;
2626
javaGenerateEqualsAndHash?: boolean;
2727
javaStringCheckUtf8?: boolean;
28-
optimizeFor?: FileOptions$OptimizeMode;
28+
optimizeFor?: IFileOptionsOptimizeMode;
2929
goPackage?: string;
3030
ccGenericServices?: boolean;
3131
javaGenericServices?: boolean;
@@ -34,121 +34,121 @@ type FileOptions$Properties = {
3434
ccEnableArenas?: boolean;
3535
objcClassPrefix?: string;
3636
csharpNamespace?: string;
37-
};
37+
}
3838

39-
type FileOptions$OptimizeMode = number;
39+
type IFileOptionsOptimizeMode = number;
4040

41-
type DescriptorProto$Properties = {
41+
export interface IDescriptorProto {
4242
name?: string;
43-
field?: FieldDescriptorProto$Properties[];
44-
extension?: FieldDescriptorProto$Properties[];
45-
nestedType?: DescriptorProto$Properties[];
46-
enumType?: EnumDescriptorProto$Properties[];
47-
extensionRange?: ExtensionRange$Properties[];
48-
oneofDecl?: OneofDescriptorProto$Properties[];
49-
options?: MessageOptions$Properties;
50-
reservedRange?: ReservedRange$Properties[];
43+
field?: IFieldDescriptorProto[];
44+
extension?: IFieldDescriptorProto[];
45+
nestedType?: IDescriptorProto[];
46+
enumType?: IEnumDescriptorProto[];
47+
extensionRange?: IDescriptorProtoExtensionRange[];
48+
oneofDecl?: IOneofDescriptorProto[];
49+
options?: IMessageOptions;
50+
reservedRange?: IDescriptorProtoReservedRange[];
5151
reservedName?: string[];
52-
};
52+
}
5353

54-
type MessageOptions$Properties = {
54+
export interface IMessageOptions {
5555
mapEntry?: boolean;
56-
};
56+
}
5757

58-
type ExtensionRange$Properties = {
58+
export interface IDescriptorProtoExtensionRange {
5959
start?: number;
6060
end?: number;
61-
};
61+
}
6262

63-
type ReservedRange$Properties = {
63+
export interface IDescriptorProtoReservedRange {
6464
start?: number;
6565
end?: number;
66-
};
66+
}
6767

68-
type FieldDescriptorProto$Properties = {
68+
export interface IFieldDescriptorProto {
6969
name?: string;
7070
number?: number;
71-
label?: FieldDescriptorProto$Label;
72-
type?: FieldDescriptorProto$Type;
71+
label?: IFieldDescriptorProtoLabel;
72+
type?: IFieldDescriptorProtoType;
7373
typeName?: string;
7474
extendee?: string;
7575
defaultValue?: string;
7676
oneofIndex?: number;
7777
jsonName?: any;
78-
options?: FieldOptions$Properties;
79-
};
78+
options?: IFieldOptionsProperties;
79+
}
8080

81-
type FieldDescriptorProto$Label = number;
81+
type IFieldDescriptorProtoLabel = number;
8282

83-
type FieldDescriptorProto$Type = number;
83+
type IFieldDescriptorProtoType = number;
8484

85-
type FieldOptions$Properties = {
85+
export interface IFieldOptions {
8686
packed?: boolean;
87-
jstype?: FieldOptions$JSType;
88-
};
87+
jstype?: IFieldOptionsJSType;
88+
}
8989

90-
type FieldOptions$JSType = number;
90+
type IFieldOptionsJSType = number;
9191

92-
type EnumDescriptorProto$Properties = {
92+
export interface IEnumDescriptorProto {
9393
name?: string;
94-
value?: EnumValueDescriptorProto$Properties[];
95-
options?: EnumOptions$Properties;
96-
};
94+
value?: IEnumValueDescriptorProto[];
95+
options?: IEnumOptions;
96+
}
9797

98-
type EnumValueDescriptorProto$Properties = {
98+
export interface IEnumValueDescriptorProto {
9999
name?: string;
100100
number?: number;
101101
options?: any;
102-
};
102+
}
103103

104-
type EnumOptions$Properties = {
104+
export interface IEnumOptions {
105105
allowAlias?: boolean;
106106
deprecated?: boolean;
107-
};
107+
}
108108

109-
type OneofDescriptorProto$Properties = {
109+
export interface IOneofDescriptorProto {
110110
name?: string;
111111
options?: any;
112-
};
112+
}
113113

114-
type ServiceDescriptorProto$Properties = {
114+
export interface IServiceDescriptorProto {
115115
name?: string;
116-
method?: MethodDescriptorProto$Properties[];
117-
options?: ServiceOptions$Properties;
118-
};
116+
method?: IMethodDescriptorProto[];
117+
options?: IServiceOptions;
118+
}
119119

120-
type ServiceOptions$Properties = {
120+
export interface IServiceOptions {
121121
deprecated?: boolean;
122-
};
122+
}
123123

124-
type MethodDescriptorProto$Properties = {
124+
export interface IMethodDescriptorProto {
125125
name?: string;
126126
inputType?: string;
127127
outputType?: string;
128-
options?: MethodOptions$Properties;
128+
options?: IMethodOptions;
129129
clientStreaming?: boolean;
130130
serverStreaming?: boolean;
131-
};
131+
}
132132

133-
type MethodOptions$Properties = {
133+
export interface IMethodOptions {
134134
deprecated?: boolean;
135-
};
135+
}
136136

137137
export const FileDescriptorSet: $protobuf.Type;
138138

139139
export const FileDescriptorProto: $protobuf.Type;
140140

141141
export const DescriptorProto: $protobuf.Type;
142142

143-
export const DescriptorProto_ExtensionRange: $protobuf.Type;
143+
export const DescriptorProtoExtensionRange: $protobuf.Type;
144144

145-
export const DescriptorProto_ReservedRange: $protobuf.Type;
145+
export const DescriptorProtoReservedRange: $protobuf.Type;
146146

147147
export const FieldDescriptorProto: $protobuf.Type;
148148

149-
export const FieldDescriptorProto_Label: $protobuf.Enum;
149+
export const FieldDescriptorProtoLabel: $protobuf.Enum;
150150

151-
export const FieldDescriptorProto_Type: $protobuf.Enum;
151+
export const FieldDescriptorProtoType: $protobuf.Enum;
152152

153153
export const OneofDescriptorProto: $protobuf.Type;
154154

@@ -162,15 +162,15 @@ export const MethodDescriptorProto: $protobuf.Type;
162162

163163
export const FileOptions: $protobuf.Type;
164164

165-
export const FileOptions_OptimizeMode: $protobuf.Enum;
165+
export const FileOptionsOptimizeMode: $protobuf.Enum;
166166

167167
export const MessageOptions: $protobuf.Type;
168168

169169
export const FieldOptions: $protobuf.Type;
170170

171-
export const FieldOptions_CType: $protobuf.Enum;
171+
export const FieldOptionsCType: $protobuf.Enum;
172172

173-
export const FieldOptions_JSType: $protobuf.Enum;
173+
export const FieldOptionsJSType: $protobuf.Enum;
174174

175175
export const OneofOptions: $protobuf.Type;
176176

@@ -184,12 +184,12 @@ export const MethodOptions: $protobuf.Type;
184184

185185
export const UninterpretedOption: $protobuf.Type;
186186

187-
export const UninterpretedOption_NamePart: $protobuf.Type;
187+
export const UninterpretedOptionNamePart: $protobuf.Type;
188188

189189
export const SourceCodeInfo: $protobuf.Type;
190190

191-
export const SourceCodeInfo_Location: $protobuf.Type;
191+
export const SourceCodeInfoLocation: $protobuf.Type;
192192

193193
export const GeneratedCodeInfo: $protobuf.Type;
194194

195-
export const GeneratedCodeInfo_Annotation: $protobuf.Type;
195+
export const GeneratedCodeInfoAnnotation: $protobuf.Type;

0 commit comments

Comments
 (0)