我这次来是带着一个非常简单的问题。在 JSDOC 上,有没有一种方法可以描述
this
在类中代表什么?
/**
* This is a very simplified version of what is going on
*
* I want to add something here to indicate that, inside this function, `this` === CalledClass,
* so autocomplete for parameters/etc work
*/
const unboundedFunction = function () {
console.log(this);
this.parameter = 50;
}
class CalledClass {
parameter = 'test';
callOutsideFunction() {
unboundedFunction.bind(this)();
}
}
const obj = new CalledClass();
obj.callOutsideFunction();
/** @this CalledClass */
const unboundedFunction = function () {
console.log(this);
this.parameter = 50;
}
class CalledClass {
parameter = 'test';
callOutsideFunction() {
unboundedFunction.bind(this)();
}
}
const obj = new CalledClass();
obj.callOutsideFunction();