md linter

This commit is contained in:
Stanley Cheung 2019-10-29 16:34:32 -07:00 committed by Stanley Cheung
parent 6272637894
commit 80358bbeaa
1 changed files with 21 additions and 15 deletions

View File

@ -1,6 +1,6 @@
## Overview
gRPC-Web provides a Javascript library that lets browser clients access a gRPC
gRPC-Web provides a JavaScript library that lets browser clients access a gRPC
service. You can find out much more about gRPC in its own
[website](https://grpc.io).
@ -103,9 +103,11 @@ also supported.
typings file will also be generated for the protobuf messages and service stub.
`import_style=typescript`: (Experimental) The service stub will be generated
in TypeScript. See **Typescript Support** below for information on how to generate Typescript files.
in TypeScript. See **TypeScript Support** below for information on how to
generate TypeScript files.
**Note: The `commonjs+dts` and `typescript` styles are only supported by `--grpc-web_out=import_style=...`, not by `--js_out=import_style=...`.**
**Note: The `commonjs+dts` and `typescript` styles are only supported by
`--grpc-web_out=import_style=...`, not by `--js_out=import_style=...`.**
### Wire Format Mode
@ -248,16 +250,17 @@ either:
- `import_style=commonjs+dts`: existing CommonJS style stub + `.d.ts` typings
- `import_style=typescript`: full TypeScript output
Do *not* use `import_style=typescript` for `--js_out`, it will silently be ignored.
Instead you should use `--js_out=import_style=commonjs`, or `--js_out=import_style=commonjs,binary`
if you are using `mode=grpcweb`. The `--js_out` plugin will generate Javascript code
(`echo_pb.js`), and the `-grpc-web_out` plugin will generate a TypeScript definition file
for it (`echo_pb.d.ts`). This is a temporary hack until the `--js_out` supports TypeScript
itself.
For example, this is the command you should use to generate TypeScript code using the
binary wire format:
Do *not* use `import_style=typescript` for `--js_out`, it will silently be
ignored. Instead you should use `--js_out=import_style=commonjs`, or
`--js_out=import_style=commonjs,binary` if you are using `mode=grpcweb`. The
`--js_out` plugin will generate JavaScript code (`echo_pb.js`), and the
`-grpc-web_out` plugin will generate a TypeScript definition file for it
(`echo_pb.d.ts`). This is a temporary hack until the `--js_out` supports
TypeScript itself.
For example, this is the command you should use to generate TypeScript code
using the binary wire format
```sh
$ protoc -I=$DIR echo.proto \
@ -267,9 +270,12 @@ $ protoc -I=$DIR echo.proto \
It will generate the following files:
* `echo_gprc_web_pb.ts` - Generated by `--grpc-web_out`, contains the TypeScript gRPC-web code.
* `echo_pb.js` - Generated by `--js_out`, contains the JavaScript Protobuf code.
* `echo_pb.d.ts` - Generated by `--grpc-web_out`, contains TypeScript definitions for `echo_pb.js`.
* `echo_grpc_web_pb.ts` - Generated by `--grpc-web_out`, contains the
TypeScript gRPC-web code.
* `echo_pb.js` - Generated by `--js_out`, contains the JavaScript Protobuf
code.
* `echo_pb.d.ts` - Generated by `--grpc-web_out`, contains TypeScript
definitions for `echo_pb.js`.
```ts
import * as grpcWeb from 'grpc-web';