Let’s say that you want to read the author name in document metadata console.log(myDoc.info.author);.
If the value is missing/empty what would you expect to be returned? Also what would you use to set an empty value back? e.g. myDoc.info.author = myVariable;
It depends on what you mean by missing/empty
If value was never set, then null. If it was set at some point, but user deleted it, it should be empty string "". But programmatically on plugin side I would probably want to have info setters and getters instead of properties.
info.setAuthor(author: string)
info.clearAuthor() (or remove/unset) would set info.author = null
I mean if user submits an empty string from input, then it should be saved as empty string. If you want to allow user explicitly completely unset some info, there should be a separate button for that or at least a checkbox, which would disable the input
I really don’t like public properties
My personal opinion
Yes. Because in fact there will be setters/getters (instead plain properties) under the hood. And in this place we can validate argument type and throw error to stop you before it is set
Also if info will be sealed then it will prevent you to accidentally add new properties and remove existing ones. Object.seal() - JavaScript | MDN
Didn’t know about seal() Then maybe it’s fine to have it like this. So I vote for null But still would like differentiation if author was never set or user deleted it