Skip to content

Protocol Buffers Compiler (protoc) plugin for TypeScript and gRPC-Web.

License

Notifications You must be signed in to change notification settings

foxdavidj/ts-protoc-gen

 
 

Repository files navigation

ts-protoc-gen

Protoc Plugin for TypeScript Declarations

Master Build NPM Apache 2.0 License quality: alpha

This repository contains a protoc plugin that generates TypeScript declarations (.d.ts files) that match the JavaScript output of protoc --js_out=import_style=commonjs,binary. This plugin can also output service definitions as .ts files in the structure required by grpc-web.

This repository also contains a plugin for generating service definitions as .js files in the structure required by grpc-web.

TypeScript Usage (with services)

  • Install this repository using npm install ts-protoc-gen or clone this repository and run npm install && npm run build
  • Invoke protoc with:
    • --plugin - define where the plugin needed for ts_out can be found
    • --js_out - the standard argument to protoc that generates .js files in the specified directory
    • --ts_out - the params and directory to output to (service=true enables outputting .ts files for services).
      • This directory must match js_out
      protoc \
      --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
      --js_out=import_style=commonjs,binary:generated \
      --ts_out=service=true:generated \
      -I ./proto \
      proto/*.proto
      

JavaScript Service Usage

  • Install this repository using npm install ts-protoc-gen or clone this repository and run npm install && npm run build
  • Invoke protoc with:
    • --plugin - define where the plugin needed for js_service_out can be found
    • --js_out - the standard argument to protoc that generates .js files in the specified directory
    • --js_service_out - define the directory to output the service definitions to.
      • This directory must match js_out
      protoc \
      --plugin=protoc-gen-js_service=./node_modules/.bin/protoc-gen-js_service \
      --js_out=import_style=commonjs,binary:generated \
      --js_service_out=generated \
      -I ./proto \
      proto/*.proto
      
      
      

TODO

  • Add tests for extensions

About

Protocol Buffers Compiler (protoc) plugin for TypeScript and gRPC-Web.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.3%
  • JavaScript 3.3%
  • Shell 1.4%