Open sayjeyhi opened 3 years ago
https://developers.google.com/protocol-buffers/docs/reference/javascript-generated#map
Why Record<string, string> instead of Map<string, string>? (perhaps obvious to a JavaScript developer) but yes, this looks contrary to the spec.
Based on spec, Map<K, V>
sounds better, and that auto-added Map
suffix is annoying! I think it is better to let users name their field names. Like what I have here, for metadata
, I don't want to have metadataMap
; I have types, and everyone using that generated type will understand the return type of this message.
Agreed that we could generate a better type here. As far as we can tell, grpc-web is just generating the type reflecting what we do.
In the meantime, if you call getMetadataMap() you should get a Map type back.
What version of protobuf and what language are you using? Version: master/v3.18 Language: Javascript
What operating system (Linux, Windows, ...) and version? Linux
What runtime / compiler are you using (e.g., python version or gcc version) Nodejs
What did you do? Steps to reproduce the behavior:
map<K, V>
so I created aproto
file like this:.ts
files is something like:Map
added to my field name! also the generated type isArray<[string, string]>
. but what we were expecting, based on language guide here, where an object of{"k": v, …}
, likeRecord<string, V>
What did you expect to see An object like:
Record<string, string>
What did you see instead?
Array<[string, string]>