Generate TypeScript definitions from a Protocol Buffers model
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 8 commits ahead, 47 commits behind SINTEF-9012:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
definitions
lib
templates
tests
.gitignore
.npmignore
LICENSE
README.md
package.json
runTests.sh

README.md

Proto2TypeScript

This tool generate TypeScript definitions for your Protocol Buffers models, when you use the excellent ProtoBuf.js library.

UPDATES -- Difference from the original

Original tool doesn't seem supported anymore.

My updates:

  • Made the package globally installable
  • Converted the tool code from Typescript to Javascript as the build process for NPM package with Typescript was not there at all
  • Fixed some bugs
  • Published on NPM

Also, the build process was a mess. I fixed those. But I don't even send a PR, because I changed a lot of stuff.

Installation

npm install proto2typescript -g

Usage

# Parse and convert the proto file to json using pbjs (from ProtoBuf.js)
pbjs model.proto > model.json

# Convert the model to TypeScript definitions
proto2typescript --file model.json > model.d.ts

Options

Options:
  -f, --file              The JSON file                                       [required]
  -c, --camelCaseGetSet   Generate getter and setters in camel case notation  [default: true]
  -u, --underscoreGetSet  Generate getter and setters in underscore notation  [default: false]
  -p, --properties        Generate properties                                 [default: true]

Gulp

See https://github.com/aliok/websocket-protobufs-ts-experiments for Gulp integration.

Why ?

Because intelligent code completion is cool :-)

Requirements

It is a Node.js project. The sourcecode is written in TypeScript, but the JavaScript output is present in the repository.

If you want to run the tests, you need bash, mocha and typescript.

npm install mocha -g
npm install typescript -g

In order to run tests:

./runTests.sh

Acknowledgements

This code is developed in context of the BRIDGE project.

Licence

The source code of this tool is licenced under the MIT License.