fields of type 'map<keyType, ValueType>' don't get setters generated
Closed this issue · 3 comments
hey there,
Thanks for all your excellent work in providing this tooling :-) We've been using this CLI since October and it's been great for us.
I am currently working with a protobuf spec that has a types map<string, TransactionType> type_mapping = 8;
Unfortunately, there is not setter generated for this field. I do get a getter and a clear function like this:
getTypeMappingMap(): jspb.Map<string, TransactionType>;
clearTypeMappingMap(): void;
I would expect a function setTypeMappingMap(value: jspb.Map<string, TransactionType>)
as part of the generated js and in the typescript declerations.
Should have mentioned: I'm using version 1.3.8
Thank you for your feedback,
When you get it from a getter, you can use **set() ** method adds or updates an element with a specified key and a value to a Map object.
like this.
...
const bookStore = new BookStore();
bookStore.setName('BOOK_STORE_NAME');
const booksMap = bookStore.getBooksMap();
booksMap.set(1, 'VALUE_1');
booksMap.set(2, 'VALUE_2');
log(`[BookStore]: ${JSON.stringify(booksMap.toObject())}`);
...
So I don't think setters need to be generated.
Thank you! After you posted this, I found it in the main docs hosted by Google: https://developers.google.com/protocol-buffers/docs/reference/javascript-generated