Skip to content

Commit

Permalink
CLI: Make sure enum typings become generated (#884 didn't solve this)…
Browse files Browse the repository at this point in the history
…; Other: Update tests
  • Loading branch information
dcodeIO committed Nov 24, 2017
1 parent ef6c825 commit 19d2af1
Show file tree
Hide file tree
Showing 18 changed files with 255 additions and 148 deletions.
20 changes: 20 additions & 0 deletions cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ function buildEnum(ref, enm) {
push("");
var comment = [
enm.comment || enm.name + " enum.",
enm.parent instanceof protobuf.Root ? "@exports " + escapeName(enm.name) : "@memberof " + exportName(enm.parent),
enm.parent instanceof protobuf.Root ? "@exports " + escapeName(enm.name) : "@name " + exportName(enm),
config.forceEnumString ? "@enum {number}" : "@enum {string}",
];
Object.keys(enm.values).forEach(function(key) {
Expand Down
80 changes: 40 additions & 40 deletions ext/descriptor/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
import * as $protobuf from "../..";

export const FileDescriptorSet: $protobuf.Type;

export const FileDescriptorProto: $protobuf.Type;

export const DescriptorProto: $protobuf.Type & { ExtensionRange: $protobuf.Type, ReservedRange: $protobuf.Type};

export const FieldDescriptorProto: $protobuf.Type & { Label: $protobuf.Enum, Type: $protobuf.Enum};

export const OneofDescriptorProto: $protobuf.Type;

export const EnumDescriptorProto: $protobuf.Type;

export const ServiceDescriptorProto: $protobuf.Type;

export const EnumValueDescriptorProto: $protobuf.Type;

export const MethodDescriptorProto: $protobuf.Type;

export const FileOptions: $protobuf.Type & { OptimizeMode: $protobuf.Enum};

export const MessageOptions: $protobuf.Type;

export const FieldOptions: $protobuf.Type & { CType: $protobuf.Enum, JSType: $protobuf.Enum};

export const OneofOptions: $protobuf.Type;

export const EnumOptions: $protobuf.Type;

export const EnumValueOptions: $protobuf.Type;

export const ServiceOptions: $protobuf.Type;

export const MethodOptions: $protobuf.Type;

export const UninterpretedOption: $protobuf.Type & { NamePart: $protobuf.Type};

export const SourceCodeInfo: $protobuf.Type & { Location: $protobuf.Type};

export const GeneratedCodeInfo: $protobuf.Type & { Annotation: $protobuf.Type};

export interface IFileDescriptorSet {
file: IFileDescriptorProto[];
}
Expand Down Expand Up @@ -133,43 +173,3 @@ export interface IMethodDescriptorProto {
export interface IMethodOptions {
deprecated?: boolean;
}

export const FileDescriptorSet: $protobuf.Type;

export const FileDescriptorProto: $protobuf.Type;

export const DescriptorProto: $protobuf.Type & { ExtensionRange: $protobuf.Type, ReservedRange: $protobuf.Type};

export const FieldDescriptorProto: $protobuf.Type & { Label: $protobuf.Enum, Type: $protobuf.Enum};

export const OneofDescriptorProto: $protobuf.Type;

export const EnumDescriptorProto: $protobuf.Type;

export const ServiceDescriptorProto: $protobuf.Type;

export const EnumValueDescriptorProto: $protobuf.Type;

export const MethodDescriptorProto: $protobuf.Type;

export const FileOptions: $protobuf.Type & { OptimizeMode: $protobuf.Enum};

export const MessageOptions: $protobuf.Type;

export const FieldOptions: $protobuf.Type & { CType: $protobuf.Enum, JSType: $protobuf.Enum};

export const OneofOptions: $protobuf.Type;

export const EnumOptions: $protobuf.Type;

export const EnumValueOptions: $protobuf.Type;

export const ServiceOptions: $protobuf.Type;

export const MethodOptions: $protobuf.Type;

export const UninterpretedOption: $protobuf.Type & { NamePart: $protobuf.Type};

export const SourceCodeInfo: $protobuf.Type & { Location: $protobuf.Type};

export const GeneratedCodeInfo: $protobuf.Type & { Annotation: $protobuf.Type};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
"scripts/postinstall.js",
"bin/**",
"cli/**",
"ext/**",
"google/**",
"ext/**",
"google/**",
"src/**"
]
}
4 changes: 2 additions & 2 deletions tests/data/comments.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface ITest1 {
field3?: (boolean|null);
}

export class Test1 {
export class Test1 implements ITest1 {
constructor(properties?: ITest1);
public field1: string;
public field2: number;
Expand All @@ -25,7 +25,7 @@ export class Test1 {
export interface ITest2 {
}

export class Test2 {
export class Test2 implements ITest2 {
constructor(properties?: ITest2);
public static create(properties?: ITest2): Test2;
public static encode(message: ITest2, writer?: $protobuf.Writer): $protobuf.Writer;
Expand Down
2 changes: 2 additions & 0 deletions tests/data/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $root.Test1 = (function() {
* with
* a
* comment.
* @implements ITest1
* @constructor
* @param {ITest1=} [properties] Properties to set
*/
Expand Down Expand Up @@ -255,6 +256,7 @@ $root.Test2 = (function() {
* Constructs a new Test2.
* @exports Test2
* @classdesc Represents a Test2.
* @implements ITest2
* @constructor
* @param {ITest2=} [properties] Properties to set
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/data/convert.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface IMessage {
int64Map?: ({ [k: string]: (number|Long) }|null);
}

export class Message {
export class Message implements IMessage {
constructor(properties?: IMessage);
public stringVal: string;
public stringRepeated: string[];
Expand Down
2 changes: 2 additions & 0 deletions tests/data/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ $root.Message = (function() {
* Constructs a new Message.
* @exports Message
* @classdesc Represents a Message.
* @implements IMessage
* @constructor
* @param {IMessage=} [properties] Properties to set
*/
Expand Down Expand Up @@ -543,6 +544,7 @@ $root.Message = (function() {

/**
* SomeEnum enum.
* @name Message.SomeEnum
* @enum {string}
* @property {number} ONE=1 ONE value
* @property {number} TWO=2 TWO value
Expand Down
8 changes: 4 additions & 4 deletions tests/data/mapbox/vector_tile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export namespace vector_tile {
layers?: (vector_tile.Tile.ILayer[]|null);
}

class Tile {
class Tile implements ITile {
constructor(properties?: vector_tile.ITile);
public layers: vector_tile.Tile.ILayer[];
public static create(properties?: vector_tile.ITile): vector_tile.Tile;
Expand Down Expand Up @@ -39,7 +39,7 @@ export namespace vector_tile {
boolValue?: (boolean|null);
}

class Value {
class Value implements IValue {
constructor(properties?: vector_tile.Tile.IValue);
public stringValue: string;
public floatValue: number;
Expand All @@ -66,7 +66,7 @@ export namespace vector_tile {
geometry?: (number[]|null);
}

class Feature {
class Feature implements IFeature {
constructor(properties?: vector_tile.Tile.IFeature);
public id: (number|Long);
public tags: number[];
Expand All @@ -92,7 +92,7 @@ export namespace vector_tile {
extent?: (number|null);
}

class Layer {
class Layer implements ILayer {
constructor(properties?: vector_tile.Tile.ILayer);
public version: number;
public name: string;
Expand Down
7 changes: 6 additions & 1 deletion tests/data/mapbox/vector_tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ $root.vector_tile = (function() {
* Constructs a new Tile.
* @memberof vector_tile
* @classdesc Represents a Tile.
* @implements ITile
* @constructor
* @param {vector_tile.ITile=} [properties] Properties to set
*/
Expand Down Expand Up @@ -224,6 +225,7 @@ $root.vector_tile = (function() {

/**
* GeomType enum.
* @name vector_tile.Tile.GeomType
* @enum {string}
* @property {number} UNKNOWN=0 UNKNOWN value
* @property {number} POINT=1 POINT value
Expand Down Expand Up @@ -258,6 +260,7 @@ $root.vector_tile = (function() {
* Constructs a new Value.
* @memberof vector_tile.Tile
* @classdesc Represents a Value.
* @implements IValue
* @constructor
* @param {vector_tile.Tile.IValue=} [properties] Properties to set
*/
Expand Down Expand Up @@ -616,6 +619,7 @@ $root.vector_tile = (function() {
* Constructs a new Feature.
* @memberof vector_tile.Tile
* @classdesc Represents a Feature.
* @implements IFeature
* @constructor
* @param {vector_tile.Tile.IFeature=} [properties] Properties to set
*/
Expand Down Expand Up @@ -958,6 +962,7 @@ $root.vector_tile = (function() {
* Constructs a new Layer.
* @memberof vector_tile.Tile
* @classdesc Represents a Layer.
* @implements ILayer
* @constructor
* @param {vector_tile.Tile.ILayer=} [properties] Properties to set
*/
Expand Down Expand Up @@ -1177,7 +1182,7 @@ $root.vector_tile = (function() {
if (!Array.isArray(message.values))
return "values: array expected";
for (var i = 0; i < message.values.length; ++i) {
error = $root.vector_tile.Tile.Value.verify(message.values[i]);
var error = $root.vector_tile.Tile.Value.verify(message.values[i]);
if (error)
return "values." + error;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/data/package.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface IPackage {
cliDependencies?: (string[]|null);
}

export class Package {
export class Package implements IPackage {
constructor(properties?: IPackage);
public name: string;
public version: string;
Expand Down Expand Up @@ -57,7 +57,7 @@ export namespace Package {
url?: (string|null);
}

class Repository {
class Repository implements IRepository {
constructor(properties?: Package.IRepository);
public type: string;
public url: string;
Expand Down
2 changes: 2 additions & 0 deletions tests/data/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ $root.Package = (function() {
* Constructs a new Package.
* @exports Package
* @classdesc Represents a Package.
* @implements IPackage
* @constructor
* @param {IPackage=} [properties] Properties to set
*/
Expand Down Expand Up @@ -681,6 +682,7 @@ $root.Package = (function() {
* Constructs a new Repository.
* @memberof Package
* @classdesc Represents a Repository.
* @implements IRepository
* @constructor
* @param {Package.IRepository=} [properties] Properties to set
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/data/rpc-es6.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface IMyRequest {
path?: (string|null);
}

export class MyRequest {
export class MyRequest implements IMyRequest {
constructor(properties?: IMyRequest);
public path: string;
public static create(properties?: IMyRequest): MyRequest;
Expand All @@ -34,7 +34,7 @@ export interface IMyResponse {
status?: (number|null);
}

export class MyResponse {
export class MyResponse implements IMyResponse {
constructor(properties?: IMyResponse);
public status: number;
public static create(properties?: IMyResponse): MyResponse;
Expand Down
2 changes: 2 additions & 0 deletions tests/data/rpc-es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const MyRequest = $root.MyRequest = (() => {
* Constructs a new MyRequest.
* @exports MyRequest
* @classdesc Represents a MyRequest.
* @implements IMyRequest
* @constructor
* @param {IMyRequest=} [properties] Properties to set
*/
Expand Down Expand Up @@ -274,6 +275,7 @@ export const MyResponse = $root.MyResponse = (() => {
* Constructs a new MyResponse.
* @exports MyResponse
* @classdesc Represents a MyResponse.
* @implements IMyResponse
* @constructor
* @param {IMyResponse=} [properties] Properties to set
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/data/rpc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface IMyRequest {
path?: (string|null);
}

export class MyRequest {
export class MyRequest implements IMyRequest {
constructor(properties?: IMyRequest);
public path: string;
public static create(properties?: IMyRequest): MyRequest;
Expand All @@ -34,7 +34,7 @@ export interface IMyResponse {
status?: (number|null);
}

export class MyResponse {
export class MyResponse implements IMyResponse {
constructor(properties?: IMyResponse);
public status: number;
public static create(properties?: IMyResponse): MyResponse;
Expand Down
2 changes: 2 additions & 0 deletions tests/data/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ $root.MyRequest = (function() {
* Constructs a new MyRequest.
* @exports MyRequest
* @classdesc Represents a MyRequest.
* @implements IMyRequest
* @constructor
* @param {IMyRequest=} [properties] Properties to set
*/
Expand Down Expand Up @@ -276,6 +277,7 @@ $root.MyResponse = (function() {
* Constructs a new MyResponse.
* @exports MyResponse
* @classdesc Represents a MyResponse.
* @implements IMyResponse
* @constructor
* @param {IMyResponse=} [properties] Properties to set
*/
Expand Down
Loading

0 comments on commit 19d2af1

Please sign in to comment.