Buffer type used despite --ts_proto_opt=env=browser
I'm running ts-proto on the following proto file using the option --ts_proto_opt=env=browser, but the node Buffer type is used in the generated code. I'm aiming to use the generated code in a non-node environment and was hoping that Uint8Array would be used instead. Am I misinterpreting the docs or is there a bug here?
test_service.ts:
export const TestServiceService = {
unaryCall: {
path: "/TestService/unaryCall",
requestStream: false,
responseStream: false,
requestSerialize: (value: ClientMessage) => Buffer.from(ClientMessage.encode(value).finish()),
requestDeserialize: (value: Buffer) => ClientMessage.decode(value),
responseSerialize: (value: ServerMessage) => Buffer.from(ServerMessage.encode(value).finish()),
responseDeserialize: (value: Buffer) => ServerMessage.decode(value),
}
}
TestService.proto:
service TestService {
rpc unaryCall (ClientMessage) returns (ServerMessage);
}
message ClientMessage {
string clientData = 1;
}
message ServerMessage {
string serverData = 1;
}
Using version 1.85.0
@peve yes, that looks like a bug, or more accurately a not-yet-supported combination of features/flags. :-)
I believe the contributors (and/or me) who've worked on streaming haven't needed browser support for it, so right, no one has made that work.
I haven't looked into how much work it would be to fix; IIRC the previous "use Buffer or UintArray" conditions are a little tedious but otherwise pretty simple.
If you'd like to submit a PR, that'd be great! Around in here:
https://github.com/stephenh/ts-proto/blob/57f24739f425ec05eabd8c8d6959d4b1b14623a1/src/generate-grpc-js.ts#L78