|
1 | 1 | grpc_tools_node_protoc_ts |
2 | 2 | ========================= |
3 | 3 |
|
| 4 | +     |
| 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 | + |
4 | 18 | ## Aim |
5 | 19 | Generate corresponding TypeScript d.ts codes according to js codes generated by [grpc_tools_node_protoc](https://www.npmjs.com/package/grpc-tools). |
6 | 20 |
|
@@ -32,10 +46,6 @@ Though the usage of tool, and generated codes shall not been changed, it's good |
32 | 46 |
|
33 | 47 | TSLint has been disabled in generated files. Please see the conversation: [#13](https://github.com/agreatfool/grpc_tools_node_protoc_ts/issues/13). |
34 | 48 |
|
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 | | - |
39 | 49 | ## How to use |
40 | 50 | ```bash |
41 | 51 | npm install grpc_tools_node_protoc_ts --save-dev |
@@ -445,33 +455,6 @@ export class BookServiceClient extends grpc.Client implements IBookServiceClient |
445 | 455 | } |
446 | 456 | ``` |
447 | 457 |
|
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 | | - |
475 | 458 | ## Changes |
476 | 459 | ### 5.0.0 |
477 | 460 | 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/ |
577 | 560 | ### 2.2.3 |
578 | 561 | Fix definitions. [fix: add missing argument grpc.Client~CallOptions for requests](https://github.com/agreatfool/grpc_tools_node_protoc_ts/pull/15/commits/ea3bff861201446346a2e6dfe511edc8f0cb6fdf) |
579 | 562 |
|
| 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 | + |
580 | 590 | ## About vulnerability |
581 | 591 | 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. |
582 | 592 |
|
|
0 commit comments