nl_tokens: The selectedItemIndex could be negative for several reasons . 1 . There are too many arguments for all of the overloads 2 . None of the overloads were type compatible The solution here is to try to pick the best overload by picking either the first one that has an appropriate number of parameters or the one with the most parameters .
pl_tokens: function selectBestInvalidOverloadIndex ( candidates , argumentCount ) { var maxParamsSignatureIndex = - 1 ; var maxParams = - 1 ; for ( var i = 0 ; i < candidates . length ; i ++ ) { var candidate = candidates [ i ] ; if ( candidate . hasRestParameter || candidate . parameters . length >= argumentCount ) { return i ; } if ( candidate . parameters . <mask> > maxParams ) { maxParams = candidate . parameters . length ; maxParamsSignatureIndex = i ; } } return maxParamsSignatureIndex ; }