The 'outputs' property at the top level of the node definition defines how many outputs it starts out with.
If you want to let the user to also be able to edit the number of outputs, you need to have an `outputs` property in the `defaults` array - but it must be a numeric value, not an object as you have it set to in the screenshot.
When you close the edit dialog, the editor checks to see if the node's outputs value has changed; if it has, it updates the appearance of the node to match.
The Function node has an input called node-input-outputs which the user can edit directly. Because of the naming convention, it just works.
The Switch node needs to set the number of outputs based on the number of rules. So its oneditsave function counts how many rules there are and updates the hidden field with the appropriate value that the editor uses to update the output count. In fact, it does a bit more than that.... because it handles reordered outputs as well as changes to how many there are. It does that by setting the node-input-outputs value as a JSON array in a special format we haven't documented. That tells the editor how the previous outputs map to its new outputs so it can maintain its wiring and keep the port labels properly lined up. If you don't need to worry about reordering outputs, then I won't go further.
Nick