Skip to content

Commit 419d69d

Browse files
committed
Update doc.
1 parent 8ca2c42 commit 419d69d

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed

README.md

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
grpc_tools_node_protoc_ts
22
=========================
33

4+
![](https://img.shields.io/badge/License-MIT-blue.svg) ![](https://img.shields.io/npm/v/grpc_tools_node_protoc_ts) ![](https://img.shields.io/npm/dw/grpc_tools_node_protoc_ts) ![](https://img.shields.io/github/stars/agreatfool/grpc_tools_node_protoc_ts) ![](https://img.shields.io/github/last-commit/agreatfool/grpc_tools_node_protoc_ts)
5+
6+
## TOC
7+
8+
* [Aim](#aim)
9+
* [Breaking changes](#breaking-changes)
10+
* [How to use](#how-to-use)
11+
* [Example](#example)
12+
* [Changes](changes)
13+
* [About jstype options of protobuf](#about-jstype-options-of-protobuf)
14+
* [About vulnerability](#about-vulnerability)
15+
* [About Docker](#about-docker)
16+
* [Environment](#environment)
17+
418
## Aim
519
Generate corresponding TypeScript d.ts codes according to js codes generated by [grpc_tools_node_protoc](https://www.npmjs.com/package/grpc-tools).
620

@@ -32,10 +46,6 @@ Though the usage of tool, and generated codes shall not been changed, it's good
3246

3347
TSLint has been disabled in generated files. Please see the conversation: [#13](https://github.com/agreatfool/grpc_tools_node_protoc_ts/issues/13).
3448

35-
## ~~Note~~
36-
~~This tools is using an unofficial grpc.d.ts definition, see: [grpc-tsd](https://www.npmjs.com/package/grpc-tsd).~~
37-
~~If you want to use this tool, you have to use definition mentioned.~~
38-
3949
## How to use
4050
```bash
4151
npm install grpc_tools_node_protoc_ts --save-dev
@@ -445,33 +455,6 @@ export class BookServiceClient extends grpc.Client implements IBookServiceClient
445455
}
446456
```
447457

448-
## About jstype options of protobuf
449-
450-
JavaScript can safely handle numbers below `Number.MAX_SAFE_INTEGER`. Beyond the limit, it begins to overflow:
451-
452-
```
453-
> 90071992547409912131 + 1
454-
90071992547409920000
455-
```
456-
457-
If you are expecting large, 64bit fields consider using a `jstype` option to override the field type.
458-
459-
```proto
460-
# example.proto
461-
message Example {
462-
fixed64 id = 1 [jstype = JS_STRING];
463-
}
464-
```
465-
466-
```typescript
467-
// example_pb.d.ts
468-
export namespace Example {
469-
export type AsObject = {
470-
id: string
471-
}
472-
}
473-
```
474-
475458
## Changes
476459
### 5.0.0
477460
Migrating to option `grpc_js` from [[email protected]](https://github.com/grpc/grpc-node/releases/tag/grpc-tools%401.9.0).
@@ -577,6 +560,33 @@ Fix issue of conflicted I{$MethodName} name, see: [Issue#19](https://github.com/
577560
### 2.2.3
578561
Fix definitions. [fix: add missing argument grpc.Client~CallOptions for requests](https://github.com/agreatfool/grpc_tools_node_protoc_ts/pull/15/commits/ea3bff861201446346a2e6dfe511edc8f0cb6fdf)
579562

563+
## About jstype options of protobuf
564+
565+
JavaScript can safely handle numbers below `Number.MAX_SAFE_INTEGER`. Beyond the limit, it begins to overflow:
566+
567+
```
568+
> 90071992547409912131 + 1
569+
90071992547409920000
570+
```
571+
572+
If you are expecting large, 64bit fields consider using a `jstype` option to override the field type.
573+
574+
```proto
575+
# example.proto
576+
message Example {
577+
fixed64 id = 1 [jstype = JS_STRING];
578+
}
579+
```
580+
581+
```typescript
582+
// example_pb.d.ts
583+
export namespace Example {
584+
export type AsObject = {
585+
id: string
586+
}
587+
}
588+
```
589+
580590
## About vulnerability
581591
Since this tool is used to generate `typescript signature` for the codes generated from `grpc_tools_node_protoc`, the codes actually run with your application are from `grpc_tools_node_protoc`, not this tool. So it's still safe to be used even there are some vulnerabilities in it.
582592

0 commit comments

Comments
 (0)