UNPKG

1.7 kBMarkdownView Raw
1# ts-protoc-gen
2> Protoc Plugin for TypeScript Declarations
3
4
5[![Master Build](https://travis-ci.org/improbable-eng/ts-protoc-gen.svg?branch=master)](https://travis-ci.org/improbable-eng/ts-protoc-gen)
6[![NPM](https://img.shields.io/npm/v/ts-protoc-gen.svg)](https://www.npmjs.com/package/ts-protoc-gen)
7[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
8![quality: alpha](https://img.shields.io/badge/quality-beta-orange.svg)
9
10This repository contains a [protoc](https://github.com/google/protobuf) plugin that generates TypeScript declarations
11(`.d.ts` files) that match the JavaScript output of `protoc --js_out=import_style=commonjs,binary`. This plugin can
12also output service definitions as both `.js` and `.d.ts` files in the structure required by [grpc-web](https://github.com/improbable-eng/grpc-web).
13
14## TypeScript Usage (with services)
15* Install this repository using `npm install ts-protoc-gen` or clone this repository and run `npm install && npm run build`
16* Invoke `protoc` with:
17 * `--plugin` - define where the plugin needed for `ts_out` can be found
18 * `--js_out` - the standard argument to `protoc` that generates `.js` files in the specified directory
19 * `--ts_out` - the params and directory to output to (`service=true` enables outputting `.js` and `.d.ts` files for use with [grpc-web](https://github.com/improbable-eng/grpc-web)).
20 * **This directory must match `js_out`**
21 ```
22 protoc \
23 --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
24 --js_out=import_style=commonjs,binary:generated \
25 --ts_out=service=true:generated \
26 -I ./proto \
27 proto/*.proto
28 ```
29
30## TODO
31* Add tests for extensions