jcompagner wrote:that one is not supported (yet)
but also i am still not really for that one to support that
i really dislike that construct. Because what does that mean? So suddenly code completion and validation must allow both types in that function for that argument
But 1 of them is just illegal and will result in wrong code.
it is way better to split that one into 2 arguments.
I disagree with you. Here are my reasons:
- Such construct is perfectly valid for JavaScript and there are multiple cases where even the Servoy methods are using it. Its meaning is the same as "method overload" in other languages, but JavaScript being a dynamic language allows the "overload" to be handled within the same method.
- The limitation which you are describing is not of the JavaScript language, but of the Servoy tool - for example the Google JSDoc-Toolkit supports it without a problem
- If inside the function, specific code applies to one of the supported types, we could use the /** @type {Type} */ tag to give the code completion a hint of what the code actually means. I have no issue if this is a requirement in order to support the multiple types @param tag.
- Applying some restrictions to new code being developed with the tool due to its limitations perhaps is OK, but I have no justification for such things when I need to refactor 200000 lines of existing code (this is how much we actually have!) to work around the tool limitation. The refactoring in this case cannot be automatic since it requires a new argument to be added to the method signature and the decision of which one to be used in every usage must be done by the programmers.
Hopefully this helps you in your decision to add support for this construct.