Skip to content

Commit

Permalink
chore: Document forceLong=bigint. Fixes #745.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenh committed Dec 29, 2022
1 parent e944e71 commit 8f8be5d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ Generated code will be placed in the Gradle build directory.

- With `--ts_proto_opt=forceLong=long`, all 64-bit numbers will be parsed as instances of `Long` (using the [long](https://www.npmjs.com/package/long) library).

Alternatively, if you pass `--ts_proto_opt=forceLong=string`, all 64-bit numbers will be outputted as strings.
With `--ts_proto_opt=forceLong=string`, all 64-bit numbers will be output as strings.

With `--ts_proto_opt=forceLong=bigint`, all 64-bit numbers will be output as `BigInt`s. This option still uses the `long` library to encode/decode internally within `protobuf.js`, but then converts to/from `BigInt`s in the ts-proto-generated code.

The default behavior is `forceLong=number`, which will internally still use the `long` library to encode/decode values on the wire (so you will still see a `util.Long = Long` line in your output), but will convert the `long` values to `number` automatically for you. Note that a runtime error is thrown if, while doing this conversion, a 64-bit value is larger than can be correctly stored as a `number`.

Expand Down

0 comments on commit 8f8be5d

Please sign in to comment.