Page 1 of 1

String.match(regexp) JSDoc Oddity

PostPosted: Wed May 31, 2017 2:22 am
by kwpsd
string.match(regexp) returns an array of strings. So the proper JSDoc nomenclature should be @return{String[]}, but Servoy creates a warning marker:

servoy_regex_match_1.png
servoy_regex_match_1.png (24 KiB) Viewed 3082 times


Changing the JSDoc nomenclature to @return{String} makes the warning maker go away but is not correct.

servoy_regex_match_2.png
servoy_regex_match_2.png (19.12 KiB) Viewed 3082 times


Am I missing something?

Re: String.match(regexp) JSDoc Oddity

PostPosted: Thu Jun 22, 2017 12:26 pm
by vschuurhof
It seems you are close. But the JSDoc notation in Servoy should not be

Code: Select all
@return {String[]}

but

Code: Select all
@return {Array<String>}

Re: String.match(regexp) JSDoc Oddity

PostPosted: Thu Jun 22, 2017 6:58 pm
by kwpsd
Well, that's interesting, because I use {String[]} in JSDoc notation everywhere with no warning or error markers (except for the String.match(regex) expression). For example:

servoy_regex_match_3.png
servoy_regex_match_3.png (46.96 KiB) Viewed 2890 times


Why does JSDoc accept {String[]} notation in some cases but not in others? If {String[]} is improper notation, why is it not flagged everywhere as a warning or error? Why does String.match(regex) appear to be a special case for JSDoc? I do not mind changing to the other notation, but I would like to know the reason for it.

Re: String.match(regexp) JSDoc Oddity

PostPosted: Fri Jun 23, 2017 8:19 am
by pbakker
String[], string[], Array<string> and Array<String> are all synonyms, so doesn't matter which one you use