Skip to content

Commit 19d2af1

Browse files
committed
CLI: Make sure enum typings become generated (#884 didn't solve this); Other: Update tests
1 parent ef6c825 commit 19d2af1

File tree

18 files changed

+255
-148
lines changed

18 files changed

+255
-148
lines changed

cli/package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/targets/static.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ function buildEnum(ref, enm) {
678678
push("");
679679
var comment = [
680680
enm.comment || enm.name + " enum.",
681-
enm.parent instanceof protobuf.Root ? "@exports " + escapeName(enm.name) : "@memberof " + exportName(enm.parent),
681+
enm.parent instanceof protobuf.Root ? "@exports " + escapeName(enm.name) : "@name " + exportName(enm),
682682
config.forceEnumString ? "@enum {number}" : "@enum {string}",
683683
];
684684
Object.keys(enm.values).forEach(function(key) {

ext/descriptor/index.d.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
import * as $protobuf from "../..";
22

3+
export const FileDescriptorSet: $protobuf.Type;
4+
5+
export const FileDescriptorProto: $protobuf.Type;
6+
7+
export const DescriptorProto: $protobuf.Type & { ExtensionRange: $protobuf.Type, ReservedRange: $protobuf.Type};
8+
9+
export const FieldDescriptorProto: $protobuf.Type & { Label: $protobuf.Enum, Type: $protobuf.Enum};
10+
11+
export const OneofDescriptorProto: $protobuf.Type;
12+
13+
export const EnumDescriptorProto: $protobuf.Type;
14+
15+
export const ServiceDescriptorProto: $protobuf.Type;
16+
17+
export const EnumValueDescriptorProto: $protobuf.Type;
18+
19+
export const MethodDescriptorProto: $protobuf.Type;
20+
21+
export const FileOptions: $protobuf.Type & { OptimizeMode: $protobuf.Enum};
22+
23+
export const MessageOptions: $protobuf.Type;
24+
25+
export const FieldOptions: $protobuf.Type & { CType: $protobuf.Enum, JSType: $protobuf.Enum};
26+
27+
export const OneofOptions: $protobuf.Type;
28+
29+
export const EnumOptions: $protobuf.Type;
30+
31+
export const EnumValueOptions: $protobuf.Type;
32+
33+
export const ServiceOptions: $protobuf.Type;
34+
35+
export const MethodOptions: $protobuf.Type;
36+
37+
export const UninterpretedOption: $protobuf.Type & { NamePart: $protobuf.Type};
38+
39+
export const SourceCodeInfo: $protobuf.Type & { Location: $protobuf.Type};
40+
41+
export const GeneratedCodeInfo: $protobuf.Type & { Annotation: $protobuf.Type};
42+
343
export interface IFileDescriptorSet {
444
file: IFileDescriptorProto[];
545
}
@@ -133,43 +173,3 @@ export interface IMethodDescriptorProto {
133173
export interface IMethodOptions {
134174
deprecated?: boolean;
135175
}
136-
137-
export const FileDescriptorSet: $protobuf.Type;
138-
139-
export const FileDescriptorProto: $protobuf.Type;
140-
141-
export const DescriptorProto: $protobuf.Type & { ExtensionRange: $protobuf.Type, ReservedRange: $protobuf.Type};
142-
143-
export const FieldDescriptorProto: $protobuf.Type & { Label: $protobuf.Enum, Type: $protobuf.Enum};
144-
145-
export const OneofDescriptorProto: $protobuf.Type;
146-
147-
export const EnumDescriptorProto: $protobuf.Type;
148-
149-
export const ServiceDescriptorProto: $protobuf.Type;
150-
151-
export const EnumValueDescriptorProto: $protobuf.Type;
152-
153-
export const MethodDescriptorProto: $protobuf.Type;
154-
155-
export const FileOptions: $protobuf.Type & { OptimizeMode: $protobuf.Enum};
156-
157-
export const MessageOptions: $protobuf.Type;
158-
159-
export const FieldOptions: $protobuf.Type & { CType: $protobuf.Enum, JSType: $protobuf.Enum};
160-
161-
export const OneofOptions: $protobuf.Type;
162-
163-
export const EnumOptions: $protobuf.Type;
164-
165-
export const EnumValueOptions: $protobuf.Type;
166-
167-
export const ServiceOptions: $protobuf.Type;
168-
169-
export const MethodOptions: $protobuf.Type;
170-
171-
export const UninterpretedOption: $protobuf.Type & { NamePart: $protobuf.Type};
172-
173-
export const SourceCodeInfo: $protobuf.Type & { Location: $protobuf.Type};
174-
175-
export const GeneratedCodeInfo: $protobuf.Type & { Annotation: $protobuf.Type};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@
117117
"scripts/postinstall.js",
118118
"bin/**",
119119
"cli/**",
120-
"ext/**",
121-
"google/**",
120+
"ext/**",
121+
"google/**",
122122
"src/**"
123123
]
124124
}

tests/data/comments.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface ITest1 {
66
field3?: (boolean|null);
77
}
88

9-
export class Test1 {
9+
export class Test1 implements ITest1 {
1010
constructor(properties?: ITest1);
1111
public field1: string;
1212
public field2: number;
@@ -25,7 +25,7 @@ export class Test1 {
2525
export interface ITest2 {
2626
}
2727

28-
export class Test2 {
28+
export class Test2 implements ITest2 {
2929
constructor(properties?: ITest2);
3030
public static create(properties?: ITest2): Test2;
3131
public static encode(message: ITest2, writer?: $protobuf.Writer): $protobuf.Writer;

tests/data/comments.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ $root.Test1 = (function() {
2727
* with
2828
* a
2929
* comment.
30+
* @implements ITest1
3031
* @constructor
3132
* @param {ITest1=} [properties] Properties to set
3233
*/
@@ -255,6 +256,7 @@ $root.Test2 = (function() {
255256
* Constructs a new Test2.
256257
* @exports Test2
257258
* @classdesc Represents a Test2.
259+
* @implements ITest2
258260
* @constructor
259261
* @param {ITest2=} [properties] Properties to set
260262
*/

tests/data/convert.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface IMessage {
1212
int64Map?: ({ [k: string]: (number|Long) }|null);
1313
}
1414

15-
export class Message {
15+
export class Message implements IMessage {
1616
constructor(properties?: IMessage);
1717
public stringVal: string;
1818
public stringRepeated: string[];

tests/data/convert.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ $root.Message = (function() {
3030
* Constructs a new Message.
3131
* @exports Message
3232
* @classdesc Represents a Message.
33+
* @implements IMessage
3334
* @constructor
3435
* @param {IMessage=} [properties] Properties to set
3536
*/
@@ -543,6 +544,7 @@ $root.Message = (function() {
543544

544545
/**
545546
* SomeEnum enum.
547+
* @name Message.SomeEnum
546548
* @enum {string}
547549
* @property {number} ONE=1 ONE value
548550
* @property {number} TWO=2 TWO value

tests/data/mapbox/vector_tile.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export namespace vector_tile {
66
layers?: (vector_tile.Tile.ILayer[]|null);
77
}
88

9-
class Tile {
9+
class Tile implements ITile {
1010
constructor(properties?: vector_tile.ITile);
1111
public layers: vector_tile.Tile.ILayer[];
1212
public static create(properties?: vector_tile.ITile): vector_tile.Tile;
@@ -39,7 +39,7 @@ export namespace vector_tile {
3939
boolValue?: (boolean|null);
4040
}
4141

42-
class Value {
42+
class Value implements IValue {
4343
constructor(properties?: vector_tile.Tile.IValue);
4444
public stringValue: string;
4545
public floatValue: number;
@@ -66,7 +66,7 @@ export namespace vector_tile {
6666
geometry?: (number[]|null);
6767
}
6868

69-
class Feature {
69+
class Feature implements IFeature {
7070
constructor(properties?: vector_tile.Tile.IFeature);
7171
public id: (number|Long);
7272
public tags: number[];
@@ -92,7 +92,7 @@ export namespace vector_tile {
9292
extent?: (number|null);
9393
}
9494

95-
class Layer {
95+
class Layer implements ILayer {
9696
constructor(properties?: vector_tile.Tile.ILayer);
9797
public version: number;
9898
public name: string;

tests/data/mapbox/vector_tile.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ $root.vector_tile = (function() {
3131
* Constructs a new Tile.
3232
* @memberof vector_tile
3333
* @classdesc Represents a Tile.
34+
* @implements ITile
3435
* @constructor
3536
* @param {vector_tile.ITile=} [properties] Properties to set
3637
*/
@@ -224,6 +225,7 @@ $root.vector_tile = (function() {
224225

225226
/**
226227
* GeomType enum.
228+
* @name vector_tile.Tile.GeomType
227229
* @enum {string}
228230
* @property {number} UNKNOWN=0 UNKNOWN value
229231
* @property {number} POINT=1 POINT value
@@ -258,6 +260,7 @@ $root.vector_tile = (function() {
258260
* Constructs a new Value.
259261
* @memberof vector_tile.Tile
260262
* @classdesc Represents a Value.
263+
* @implements IValue
261264
* @constructor
262265
* @param {vector_tile.Tile.IValue=} [properties] Properties to set
263266
*/
@@ -616,6 +619,7 @@ $root.vector_tile = (function() {
616619
* Constructs a new Feature.
617620
* @memberof vector_tile.Tile
618621
* @classdesc Represents a Feature.
622+
* @implements IFeature
619623
* @constructor
620624
* @param {vector_tile.Tile.IFeature=} [properties] Properties to set
621625
*/
@@ -958,6 +962,7 @@ $root.vector_tile = (function() {
958962
* Constructs a new Layer.
959963
* @memberof vector_tile.Tile
960964
* @classdesc Represents a Layer.
965+
* @implements ILayer
961966
* @constructor
962967
* @param {vector_tile.Tile.ILayer=} [properties] Properties to set
963968
*/
@@ -1177,7 +1182,7 @@ $root.vector_tile = (function() {
11771182
if (!Array.isArray(message.values))
11781183
return "values: array expected";
11791184
for (var i = 0; i < message.values.length; ++i) {
1180-
error = $root.vector_tile.Tile.Value.verify(message.values[i]);
1185+
var error = $root.vector_tile.Tile.Value.verify(message.values[i]);
11811186
if (error)
11821187
return "values." + error;
11831188
}

0 commit comments

Comments
 (0)