From c0ab94c2e469c0fbf790e4807f24fddd6370e342 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Fri, 30 Dec 2016 01:52:19 +0100 Subject: [PATCH] Other: Reference dependencies as imports in generated typescript definitions, see #596 --- cli/pbts.js | 11 +++++++++-- types/protobuf.js.d.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cli/pbts.js b/cli/pbts.js index ccb0f4fc8..09856d599 100644 --- a/cli/pbts.js +++ b/cli/pbts.js @@ -93,8 +93,15 @@ exports.main = function(args, callback) { var output = [ "// $> pbts " + process.argv.slice(2).join(' '), - "// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC"), - ].join('\n') + "\n" + out.join(''); + "// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC") + ]; + if (argv.name !== "protobufjs") + output.push( + "", + "import { Reader, Writer } from \"protobufjs\";", + "" + ); + output = output.join('\n') + "\n" + out.join(''); try { if (argv.out) diff --git a/types/protobuf.js.d.ts b/types/protobuf.js.d.ts index bebdc0786..80d909149 100644 --- a/types/protobuf.js.d.ts +++ b/types/protobuf.js.d.ts @@ -1,5 +1,5 @@ // $> pbts --name protobufjs --out types/protobuf.js.d.ts src -// Generated Thu, 29 Dec 2016 16:24:14 UTC +// Generated Fri, 30 Dec 2016 00:51:27 UTC declare module "protobufjs" { /**