I am moving from Javascript to Typescript and am trying to create a class method which can take a JQuery object or an array of them. I am trying to use a union type but cannot seem to get the matching to work with the JQuery parameter:
setToGrey($items: JQuery[]|JQuery) {
if ($items instanceof Array) {
for (var i = 0; i < $items.length; i++) {
var $item = $items[i];
this.resetIcon($item);
$item.addClass(CSSClasses.TEXT_MUTED).find("span." + CSSClasses.GLYPHICON).addClass(CSSClasses.ICON_QUESTION_CICLE);
}
} else if ($items instanceof JQuery) {
this.resetIcon($items);
$items.addClass(CSSClasses.TEXT_MUTED).find("span." + CSSClasses.GLYPHICON).addClass(CSSClasses.ICON_QUESTION_CICLE);
}
}
I cannot get the line:
} else if ($items instanceof JQuery) {
to work, the error comes up as Cannot find name 'JQuery'.
I'm not sure where my misunderstanding is. What am I doing wrong?