80function setupManagementEvents() {
81 if(staffInfo === null || !staffInfo.actions) return;
82 $<HTMLSelectElement>("select.post-actions").each(addManageEvents);
83 $(document).on("postDropdownAdded", function(_e, data) { 84 if(!data.dropdown) return; 85 data.dropdown.append("<option>Posts from this IP</option>"); 86 data.dropdown.append("<option>Ban IP address</option>"); 87 }); 88}
89
90interface BanFileJSON {
It is recommended to use arrow functions as callbacks.
Arrow functions can be an attractive alternative to function expressions for callbacks or function arguments.
For example, arrow functions are automatically bound to their surrounding scope/context. This provides an alternative to the pre-ES6 standard of explicitly binding function expressions to achieve similar behavior.
Additionally, arrow functions are:
less verbose, and easier to reason about.
bound lexically regardless of where or when they are invoked.
func(function(a) { return a; }); // ERROR
// prefer: func(a => a)
func(function() { return this.a; }.bind(this)); // ERROR
// prefer: func(() => this.a)
// arrow function callback
func(a => a); // OK
// generator as callback
func(function*() { yield; }); // OK
// function expression not used as callback or function argument
var funcVar = function func(a) { return a; }; // OK
// unbound function expression callback
func(function() { return this.a; }); // OK
// recursive named function callback
func(function recursiveFunc(n) { return n && n + recursiveFunc(n - 1); }); // OK