diff --git a/collection/collection-tests.ts b/collection/collection-tests.ts
deleted file mode 100644
index 6f81ca872a..0000000000
--- a/collection/collection-tests.ts
+++ /dev/null
@@ -1,94 +0,0 @@
-///
-
-// there are various instances in these tests when the type
-// is provided, this is to prevent the compiler from complaining
-// when I violate the type enforcement posed by the various
-// collection types.
-
-var assortment: Assortment = {}
-
-function testAssortment() {
- // assortments can be indexed by either number or string
- assortment[0] = 0;
- assortment['1'] = 1;
-
- // assortments can store any type
- assortment['a'] = 'a';
- assortment['true'] = true;
-}
-
-testAssortment();
-
-
-var collection: Collection = {};
-
-function testCollection() {
- // collections can be indexed by either number or string
- collection[0] = 0;
- collection['1'] = 1;
-
- // a collection can always be expected to provide back its type
- var zero: number = collection[0];
- var one: number = collection[1];
-
- // collections should not store values that aren't of their type
- collection['b'] = 'b'; // would have thrown compiler error
-
- // collections also should not return values that aren't their type
- var b: string = collection['b']; // would have thrown compiler error
-}
-
-testCollection();
-
-
-var dictionary: Dictionary = {};
-
-function testDictionary() {
- // dictionarys can store any type and are indexed by string
- dictionary['b'] = 'b';
- dictionary['1'] = 1;
- dictionary['true'] = true;
-
- // also, hopefully in the future, Dictionarys will error with these expressions as well
- // However, TypeScript currently does not enforce key types for arrays
-
- // dictionarys should not use any index value, but string
- var newDictionary: Dictionary = {0: 'a', 'b': 'b'}; // should have thrown compiler error
- var a: string = newDictionary[0]; // should have thrown compiler error
- newDictionary[1] = '1'; // should have thrown compiler error
-
- // dictionarys should be used with type checking because of this
- if (typeof dictionary['b'] == 'string') {
- var b_str: string = dictionary['b'];
- } else if (typeof dictionary['b'] == 'number') {
- var b_num: number = dictionary['b'];
- }
-
- // but we can also just take the value if we don't care about the type
- var one: any = dictionary['1'];
-}
-
-testDictionary();
-
-
-var thesaurus: Thesaurus = {};
-
-function testThesaurus() {
- // a thesaurus is indexed by string
- thesaurus['word'] = 'a combination of varters';
-
- // it should not be indexed with any other value, but it can
- // in the current build of TypeScript
- var newThesaurus: Thesaurus = {0: '0', '1': '1'}; // should have thrown compiler
- // error
- var zero: string = newThesaurus[0]; // should have thrown compiler error
- newThesaurus[1] = '1'; // should have thrown compile error
-
- // a thesaurus will return its respective value
- var word: string = thesaurus['word'];
-
- // assigning any other type will throw a compiler error
- thesaurus['two'] = 2; // would have thrown compiler error
- // expecting any other type will throw a compiler error
- var two: number = thesaurus['two']; // would have thrown compiler error
-}
\ No newline at end of file
diff --git a/collection/collection.d.ts b/collection/collection.d.ts
deleted file mode 100644
index 8b203d554f..0000000000
--- a/collection/collection.d.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-// Type definitions for collections
-// Project: https://github.com/ttowncompiled/DefinitelyTyped
-// Definitions by: Ian Riley
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-
-// an Assortment allows a variety of types, and each object can be referenced
-// by number or by string.
-interface Assortment {
- [key: number]: any;
- [key: string]: any;
-}
-
-// a Collection only allows a single type, and each object can be referenced
-// by number or by string.
-interface Collection {
- [key: number]: T;
- [key: string]: T;
-}
-
-// a Dictionary allows a variety of types, but each object must be referenced by string.
-interface Dictionary {
- [key: string]: any;
-}
-
-// a Thesaurus only allows a single type, but each object must be referenced by string.
-interface Thesaurus {
- [key: string]: T;
-}
-
-// an object that allows a variety of types, but each object is referenced by number
-// is: any[]
-// an object that allows only a single type, but each object is referenced by number
-// is: T[]
diff --git a/protobufjs/protobufjs-tests.ts b/protobufjs/protobufjs-tests.ts
index 43704496f1..8cf52b274b 100644
--- a/protobufjs/protobufjs-tests.ts
+++ b/protobufjs/protobufjs-tests.ts
@@ -1,8 +1,8 @@
///
///
-import {assert} from 'chai';
-import {readFileSync} from 'fs';
+var assert = require('chai').assert;
+var readFileSync = require('fs').readFileSync;
import ProtoBuf = require("protobufjs");
function testProtoBufJs() {
@@ -23,7 +23,7 @@ function testProtoBufJs() {
var jsonFileProto: ProtoBuf.ProtoBuilder = ProtoBuf.loadJsonFile("test.json");
assertIsProtoBuilder(jsonFileProto, "loadJsonFile");
- ProtoBuf.loadJsonFile("test.json", (error, builder: ProtoBuf.ProtoBuilder) => {
+ ProtoBuf.loadJsonFile("test.json", (error: any, builder: ProtoBuf.ProtoBuilder) => {
assertIsProtoBuilder(builder, "loadJsonFile callback");
});
@@ -34,7 +34,7 @@ function testProtoBufJs() {
var protoFile: ProtoBuf.ProtoBuilder = ProtoBuf.loadProtoFile("test.proto");
assertIsProtoBuilder(protoFile, "loadProtoFile");
- ProtoBuf.loadProtoFile("test.proto", (error, builder: ProtoBuf.ProtoBuilder) => {
+ ProtoBuf.loadProtoFile("test.proto", (error: any, builder: ProtoBuf.ProtoBuilder) => {
assertIsProtoBuilder(builder, "loadProtoFile callback");
});
diff --git a/protobufjs/protobufjs.d.ts b/protobufjs/protobufjs.d.ts
index b098287837..55d2bea66e 100644
--- a/protobufjs/protobufjs.d.ts
+++ b/protobufjs/protobufjs.d.ts
@@ -3,7 +3,6 @@
// Definitions by: Panu Horsmalahti
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-///
///
declare module ProtoBuf {
@@ -32,31 +31,28 @@ declare module ProtoBuf {
callback?: (error: any, builder: ProtoBuilder) => void,
builder?: ProtoBuilder): ProtoBuilder;
- export function newBuilder(options?: Dictionary): ProtoBuilder;
+ export function newBuilder(options?: {[key: string]: any}): ProtoBuilder;
// ==========
// protobufjs/src/ProtoBuf/Builder.js
- /**
- * TODO: constructor returns type ProtoBuilder
- */
export interface Builder {
- (options?: Dictionary): void; // returns ProtoBuilder
+ new(options?: {[key: string]: any}): ProtoBuilder;
Message: Message;
Service: Service;
- isValidMessage(def: Dictionary): boolean;
- isValidMessageField(def: Dictionary): boolean;
- isValidEnum(def: Dictionary): boolean;
- isValidService(def: Dictionary): boolean;
- isValidExtend(def: Dictionary): boolean;
+ isValidMessage(def: {[key: string]: any}): boolean;
+ isValidMessageField(def: {[key: string]: any}): boolean;
+ isValidEnum(def: {[key: string]: any}): boolean;
+ isValidService(def: {[key: string]: any}): boolean;
+ isValidExtend(def: {[key: string]: any}): boolean;
}
/**
* TODO: Confirm that message needs no further implementation
*/
export interface Message {
- (values?: Dictionary, var_args?: string[]): void;
+ new(values?: {[key: string]: any}, var_args?: string[]): Message;
[field: string]: any;
}
@@ -64,7 +60,7 @@ declare module ProtoBuf {
* TODO: Implement service interface
*/
export interface Service {
- (rpcImpl?: Function): void;
+ new(rpcImpl?: Function): Service;
}
@@ -78,22 +74,22 @@ declare module ProtoBuf {
result: ProtoBuf;
files: string[];
importRoot: string;
- options: Dictionary;
+ options: {[key: string]: any};
syntax: string;
reset(): void;
- define(pkg: string, options?: Dictionary): ProtoBuilder;
- create(defs?: Dictionary[]): ProtoBuilder;
+ define(pkg: string, options?: {[key: string]: any}): ProtoBuilder;
+ create(defs?: {[key: string]: any}[]): ProtoBuilder;
resolveAll(): void;
build(path?: string): ProtoBuf;
lookup(path?: string): ReflectT;
}
export interface ProtoBuf {
- [package: string]: Thesaurus;
+ [package: string]: {[key: string]: MetaMessage | any};
}
export interface MetaMessage {
- (values?: Dictionary, var_args?: string[]): void; // returns Message
+ new(values?: {[key: string]: any}, var_args?: string[]): Message;
decode(buffer?: Buffer, enc?: string): Message;
decodeDelimited(buffer?: Buffer, enc?: string): Message;
decode64(str: string): Message;
@@ -109,14 +105,14 @@ declare module ProtoBuf {
}
export interface Parser {
- (proto: string): void;
+ new(proto: string): Parser;
tn: Tokenizer;
parse(): MetaProto;
toString(): string;
}
export interface Tokenizer {
- (proto: string): void;
+ new(proto: string): Tokenizer;
source: string;
index: number;
line: number;
@@ -136,14 +132,14 @@ declare module ProtoBuf {
messages: ProtoMessage[];
enums: ProtoEnum[];
imports: string[];
- options: Dictionary;
+ options: {[key: string]: any};
services: ProtoService[];
}
export interface ProtoEnum {
name: string;
values: ProtoEnumValue;
- options: Dictionary;
+ options: {[key: string]: any};
}
export interface ProtoEnumValue {
@@ -153,7 +149,7 @@ declare module ProtoBuf {
export interface ProtoField {
rule: string;
- options: Dictionary;
+ options: {[key: string]: any};
type: string;
name: string;
id: number;
@@ -166,20 +162,20 @@ declare module ProtoBuf {
fields: ProtoField[];
enums: ProtoEnum[];
messages: ProtoMessage[];
- options: Dictionary;
- oneofs: Thesaurus;
+ options: {[key: string]: any};
+ oneofs: {[key: string]:number[]};
}
export interface ProtoRpcService {
request: string;
response: string;
- options: Dictionary;
+ options: {[key: string]: any};
}
export interface ProtoService {
name: string;
- rpc: Thesaurus;
- options: Dictionary;
+ rpc: {[key: string]:ProtoRpcService};
+ options: {[key: string]: any};
}
@@ -196,7 +192,7 @@ declare module ProtoBuf {
}
export interface ReflectT {
- (builder?: ProtoBuilder, parent?: ReflectT, name?: string): void;
+ new(builder?: ProtoBuilder, parent?: ReflectT, name?: string): ReflectT;
builder: ProtoBuilder;
parent: ReflectT;
name: string;
@@ -205,72 +201,74 @@ declare module ProtoBuf {
}
export interface ReflectNamespace extends ReflectT {
- (builder?: ProtoBuilder, parent?: ReflectNamespace, name?: string,
- options?: Dictionary): void;
+ new(builder?: ProtoBuilder, parent?: ReflectNamespace, name?: string,
+ options?: {[key: string]: any}): ReflectNamespace;
className: string;
children: ReflectT[];
- options: Dictionary;
+ options: {[key: string]: any};
syntax: string;
getChildren(type?: ReflectT): ReflectT[];
addChild(child: ReflectT): void;
getChild(nameOrId?: string | number): ReflectT;
resolve(qn: string, excludeFields?: boolean): ReflectNamespace;
- build(): any; // TODO: discover the return type of build
- buildOpt(): Dictionary;
+ build(): ProtoBuf;
+ buildOpt(): {[key: string]: any};
getOption(name?: string): any;
}
export interface ReflectMessage extends ReflectNamespace {
- (builder?: ProtoBuilder, parent?: ReflectNamespace, name?: string,
- options?: Dictionary, isGroup?: boolean): void;
- Field: ReflectField; // TODO: only for new ProtoBuf.Reflect.Message.Field();
- ExtensionField: ReflectExtensionField; // TODO: only for
+ new(builder?: ProtoBuilder, parent?: ReflectNamespace, name?: string,
+ options?: {[key: string]: any}, isGroup?: boolean): ReflectMessage;
+ Field: ReflectField; // NOTE: only for new ProtoBuf.Reflect.Message.Field();
+ ExtensionField: ReflectExtensionField; // NOTE: only for
// new ProtoBuf.Reflect.Message.ExtensionField();
- OneOf: ReflectOneOf; // TODO: only for new ProtoBuf.Reflect.Message.OneOf();
+ OneOf: ReflectOneOf; // NOTE: only for new ProtoBuf.Reflect.Message.OneOf();
extensions: number[];
- clazz(): any; //TODO: discover type of clazz
+ clazz(): MetaMessage;
isGroup: boolean;
- build(rebuild?: boolean): any; // TODO: discover the return type of build
+ build(rebuild?: boolean): MetaMessage|any;
encode(message: Message, buffer: Buffer, noVerify?: boolean): Buffer;
calculate(message: Message): number;
decode(buffer: Buffer, length?: number, expectedGroupEndId?: number): Message;
}
export interface ReflectEnum extends ReflectNamespace {
- (builder?: ProtoBuilder, parent?: ReflectT, name?: string,
- options?: Dictionary): void;
- Value: ReflectValue; // TODO: only for new ProtoBuf.Reflect.Enum.Value();
- object: Thesaurus;
- build(): any; // TODO: discover the return type of build
+ new(builder?: ProtoBuilder, parent?: ReflectT, name?: string,
+ options?: {[key: string]: any}): ReflectEnum;
+ Value: ReflectValue; // NOTE: only for new ProtoBuf.Reflect.Enum.Value();
+ object: {[key: string]:number};
+ build(): {[key: string]: any};
}
export interface ReflectExtension extends ReflectT {
- (builder?: ProtoBuilder, parent?: ReflectT, name?: string, field?: ReflectField): void;
+ new(builder?: ProtoBuilder, parent?: ReflectT, name?: string,
+ field?: ReflectField): ReflectExtension;
field: ReflectField;
}
export interface ReflectService extends ReflectNamespace {
- Method: ReflectMethod; // TODO: only for new ProtoBuf.Reflect.Service.Method();
- RPCMethod: ReflectRPCMethod; // TODO: only for new ProtoBuf.Reflect.Service.RPCMethod();
- clazz(): any; // TODO: discover type of clazz
- build(rebuild?: boolean): any; // TODO: discover the return type of build
+ new(): ReflectService;
+ Method: ReflectMethod; // NOTE: only for new ProtoBuf.Reflect.Service.Method();
+ RPCMethod: ReflectRPCMethod; // NOTE: only for new ProtoBuf.Reflect.Service.RPCMethod();
+ clazz(): Function;
+ build(rebuild?: boolean): Function|any;
}
// TODO: check that the runtime instance of this type reflects this definition
export interface ReflectField extends ReflectT {
- (builder: ProtoBuilder, message: ReflectMessage, rule: string, type: string,
- name: string, id: number, options: Dictionary, oneof: ReflectOneOf): void;
+ new(builder: ProtoBuilder, message: ReflectMessage, rule: string, type: string,
+ name: string, id: number, options: {[key: string]: any}, oneof: ReflectOneOf): ReflectField;
className: string;
required: boolean;
repeated: boolean;
type: string | WireTuple;
resolvedType: ReflectT;
id: number;
- options: Dictionary;
+ options: {[key: string]: any};
defaultValue: any;
oneof: ReflectOneOf;
originalName: string;
- build(): any; // TODO: discover the return type of build
+ build(): {[key: string]: any};
mkLong(value: any, unsigned?: boolean): number;
verifyValue(value: any, skipRepeated?: boolean): any;
encode(value: any, buffer: Buffer): Buffer;
@@ -287,32 +285,33 @@ declare module ProtoBuf {
// TODO: check that the runtime instance of this type reflects this definition
export interface ReflectExtensionField extends ReflectField {
- (builder: ProtoBuilder, message: ReflectMessage, rule: string, type: string,
- name: string, id: number, options: Dictionary): void;
+ new(builder: ProtoBuilder, message: ReflectMessage, rule: string, type: string,
+ name: string, id: number, options: {[key: string]: any}): ReflectExtensionField;
extension: ReflectExtension;
}
export interface ReflectOneOf extends ReflectT {
- (builder: ProtoBuilder, message: ReflectMessage, name: string): void;
+ new(builder?: ProtoBuilder, message?: ReflectMessage, name?: string): ReflectOneOf;
fields: ReflectField[];
}
export interface ReflectValue extends ReflectT {
- (builder?: ProtoBuilder, enm?: ReflectEnum, name?: string, id?: number): void;
+ new(builder?: ProtoBuilder, enm?: ReflectEnum, name?: string, id?: number): ReflectValue;
className: string;
id: number;
}
export interface ReflectMethod extends ReflectT {
- (builder: ProtoBuilder, svc: ReflectService, name: string, options: Dictionary): void;
+ new(builder?: ProtoBuilder, svc?: ReflectService, name?: string,
+ options?: {[key: string]: any}): ReflectMethod;
className: string;
- options: Dictionary;
- buildOpt(): Dictionary;
+ options: {[key: string]: any};
+ buildOpt(): {[key: string]: any};
}
export interface ReflectRPCMethod extends ReflectMethod {
- (builder: ProtoBuilder, svc: ReflectService, name: string, request: string,
- response: string, options: Dictionary): void;
+ new(builder?: ProtoBuilder, svc?: ReflectService, name?: string, request?: string,
+ response?: string, options?: {[key: string]: any}): ReflectRPCMethod;
requestName: string;
responseName: string;
resolvedRequestType: ReflectMessage;