Merge pull request #3402 from panuhorsmalahti/protobuf

Add initial type definitions for ProtoBuf.js
This commit is contained in:
Masahiro Wakame
2015-01-04 01:06:58 +09:00
2 changed files with 34 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
/// <reference path="protobufjs.d.ts" />
import ProtoBuf = require("protobufjs");
ProtoBuf.loadProtoFile("test.proto", builder => {
builder.build();
var message: ProtoBuf.IProtoBufMessage;
message.toArrayBuffer();
message.toBuffer();
});
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for ProtoBuf.js
// Project: https://github.com/dcodeIO/ProtoBuf.js
// Definitions by: Panu Horsmalahti <https://github.com/panuhorsmalahti>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module ProtoBuf {
export interface IBuilder {
build: <T>() => T;
}
export interface IProtoBufMessage {
toArrayBuffer(): ArrayBuffer;
toBuffer(): Buffer;
}
export function loadProtoFile(filePath: string, callback: (builder: IBuilder) => void): any;
}
declare module "protobufjs" {
export = ProtoBuf;
}