From 8f6b1c8718931967a6dfaff25edf23c5179b3fc4 Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Fri, 2 Jan 2015 15:41:40 +0200 Subject: [PATCH 1/7] Add initial type definitions for ProtoBuf.js --- protobuf/protobuf-tests.ts | 11 +++++++++++ protobuf/protobuf.d.ts | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 protobuf/protobuf-tests.ts create mode 100644 protobuf/protobuf.d.ts 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; +} From c8d2e0465980d28cc29052513517a71188ce9d82 Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Fri, 2 Jan 2015 15:48:06 +0200 Subject: [PATCH 2/7] Fix the tests and export interfaces --- protobuf/protobuf-tests.ts | 1 + protobuf/protobuf.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/protobuf/protobuf-tests.ts b/protobuf/protobuf-tests.ts index 7b910d380..077522900 100644 --- a/protobuf/protobuf-tests.ts +++ b/protobuf/protobuf-tests.ts @@ -1,4 +1,5 @@ /// +/// import ProtoBuf = require("protobufjs"); diff --git a/protobuf/protobuf.d.ts b/protobuf/protobuf.d.ts index bbd4736c8..5e758e7a4 100644 --- a/protobuf/protobuf.d.ts +++ b/protobuf/protobuf.d.ts @@ -4,11 +4,11 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module ProtoBuf { - interface IBuilder { + export interface IBuilder { build: () => T; } - interface IProtoBufMessage { + export interface IProtoBufMessage { toArrayBuffer(): ArrayBuffer; toBuffer(): Buffer; } From c8f3bc75d4979051aa3ff03027849068be46152f Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Fri, 2 Jan 2015 15:51:20 +0200 Subject: [PATCH 3/7] Move the node dependency to protobuf.d.ts from tests --- protobuf/protobuf-tests.ts | 1 - protobuf/protobuf.d.ts | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/protobuf/protobuf-tests.ts b/protobuf/protobuf-tests.ts index 077522900..7b910d380 100644 --- a/protobuf/protobuf-tests.ts +++ b/protobuf/protobuf-tests.ts @@ -1,5 +1,4 @@ /// -/// import ProtoBuf = require("protobufjs"); diff --git a/protobuf/protobuf.d.ts b/protobuf/protobuf.d.ts index 5e758e7a4..f300beb54 100644 --- a/protobuf/protobuf.d.ts +++ b/protobuf/protobuf.d.ts @@ -3,6 +3,8 @@ // Definitions by: Panu Horsmalahti // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module ProtoBuf { export interface IBuilder { build: () => T; From a7852e85fdcbb6de0173c5b48a9adfb58ff8ccab Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Fri, 2 Jan 2015 15:55:06 +0200 Subject: [PATCH 4/7] Add github url --- protobuf/protobuf.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobuf/protobuf.d.ts b/protobuf/protobuf.d.ts index f300beb54..66a48dc78 100644 --- a/protobuf/protobuf.d.ts +++ b/protobuf/protobuf.d.ts @@ -1,6 +1,6 @@ // Type definitions for ProtoBuf.js // Project: https://github.com/dcodeIO/ProtoBuf.js -// Definitions by: Panu Horsmalahti +// Definitions by: Panu Horsmalahti // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 09f3af655c028246abf97e00775a316ffb4b38f0 Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Sat, 3 Jan 2015 16:52:36 +0200 Subject: [PATCH 5/7] Renamed protobuf to protobufjs --- protobuf/protobuf-tests.ts => protobufjs/protobufjs-tests.d.ts | 0 protobuf/protobuf.d.ts => protobufjs/protobufjs.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename protobuf/protobuf-tests.ts => protobufjs/protobufjs-tests.d.ts (100%) rename protobuf/protobuf.d.ts => protobufjs/protobufjs.d.ts (100%) diff --git a/protobuf/protobuf-tests.ts b/protobufjs/protobufjs-tests.d.ts similarity index 100% rename from protobuf/protobuf-tests.ts rename to protobufjs/protobufjs-tests.d.ts diff --git a/protobuf/protobuf.d.ts b/protobufjs/protobufjs.d.ts similarity index 100% rename from protobuf/protobuf.d.ts rename to protobufjs/protobufjs.d.ts From ec1eafa840a6e7886c3ac51d374156ec60454cfd Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Sat, 3 Jan 2015 16:54:12 +0200 Subject: [PATCH 6/7] Renamed the test file --- protobufjs/{protobufjs-tests.d.ts => protobufjs-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename protobufjs/{protobufjs-tests.d.ts => protobufjs-tests.ts} (100%) diff --git a/protobufjs/protobufjs-tests.d.ts b/protobufjs/protobufjs-tests.ts similarity index 100% rename from protobufjs/protobufjs-tests.d.ts rename to protobufjs/protobufjs-tests.ts From b344b6491c3a0a675ecdeb479648505eef7cc4ef Mon Sep 17 00:00:00 2001 From: Panu Horsmalahti Date: Sat, 3 Jan 2015 16:55:53 +0200 Subject: [PATCH 7/7] Fixed the test. --- protobufjs/protobufjs-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobufjs/protobufjs-tests.ts b/protobufjs/protobufjs-tests.ts index 7b910d380..148eb05e3 100644 --- a/protobufjs/protobufjs-tests.ts +++ b/protobufjs/protobufjs-tests.ts @@ -1,4 +1,4 @@ -/// +/// import ProtoBuf = require("protobufjs");