diff --git a/protobuf/protobuf-tests.ts b/protobuf/protobuf-tests.ts new file mode 100644 index 000000000..7b910d380 --- /dev/null +++ b/protobuf/protobuf-tests.ts @@ -0,0 +1,11 @@ +/// + +import ProtoBuf = require("protobufjs"); + +ProtoBuf.loadProtoFile("test.proto", builder => { + builder.build(); + + var message: ProtoBuf.IProtoBufMessage; + message.toArrayBuffer(); + message.toBuffer(); +}); diff --git a/protobuf/protobuf.d.ts b/protobuf/protobuf.d.ts new file mode 100644 index 000000000..bbd4736c8 --- /dev/null +++ b/protobuf/protobuf.d.ts @@ -0,0 +1,21 @@ +// Type definitions for ProtoBuf.js +// Project: https://github.com/dcodeIO/ProtoBuf.js +// Definitions by: Panu Horsmalahti +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module ProtoBuf { + interface IBuilder { + build: () => T; + } + + interface IProtoBufMessage { + toArrayBuffer(): ArrayBuffer; + toBuffer(): Buffer; + } + + export function loadProtoFile(filePath: string, callback: (builder: IBuilder) => void): any; +} + +declare module "protobufjs" { + export = ProtoBuf; +}