Add initial type definitions for ProtoBuf.js

This commit is contained in:
Panu Horsmalahti
2015-01-02 15:41:40 +02:00
parent ec6e0ae952
commit 8f6b1c8718
2 changed files with 32 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
/// <reference path="protobuf.d.ts" />
import ProtoBuf = require("protobufjs");
ProtoBuf.loadProtoFile("test.proto", builder => {
builder.build();
var message: ProtoBuf.IProtoBufMessage;
message.toArrayBuffer();
message.toBuffer();
});
+21
View File
@@ -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>() => T;
}
interface IProtoBufMessage {
toArrayBuffer(): ArrayBuffer;
toBuffer(): Buffer;
}
export function loadProtoFile(filePath: string, callback: (builder: IBuilder) => void): any;
}
declare module "protobufjs" {
export = ProtoBuf;
}