Support custom types for integers
Currently ts-proto treats any integer types in .proto as typescript number type. This is not always desirable since it can be a source of bugs, e.g., unintentional integer overflow, loss of precision(fraction), etc,..
It would be great to have an option emitting more specific types.
- type conversion code location: https://github.com/stephenh/ts-proto/blob/348a4651b42d5ff64fd07e36ef9ca7d7e76f4277/src/types.ts#L68
- Note: grpc-web has a similar feature request https://github.com/grpc/grpc-web/issues/1229
cc @Lanace
Hey @kkimdev , happy to accept PRs that implement what you need.
Fwiw at some point we'll be dependent on what the underlying protobuf.js encoders/decoders offer in terms of runtime behavior, i.e. their reader.float() method returns a number:
/**
* Reads a float (32 bit) as a number.
* @returns Value read
*/
public float(): number;
Not sure if this is something they've changed in newer releases, or how easy it'd be to fix, but would be something to take into account. Thanks!