declare global { interface Set { /** @summary check if any of the elements of `arr2` are included in `this` */ anyOf(arr2: Array): boolean; /** @summary return set items as array */ arr(): Array; } } Set.prototype.arr = function() { return Array.from(this); } Set.prototype.anyOf = function(arr2) { return !!this.arr().filter(e => arr2.includes(e)).length; };