Im tryin to pass the parameter 'this' to a function this way:
modalshow = new Confirmation(false, this.changea(this), this.changer);
and the Confirmation Class is like this:
constructor(
public show: boolean,
public actionAccept: Function,
public actionReject: Function
) {}
But i keep getting the error:
Argument of type 'void' is not assignable to parameter of type 'Function'
So, i don't know what is the problem and what should i do.
Im tryin to pass the parameter 'this' to a function this way:
modalshow = new Confirmation(false, this.changea(this), this.changer);
and the Confirmation Class is like this:
constructor(
public show: boolean,
public actionAccept: Function,
public actionReject: Function
) {}
But i keep getting the error:
Argument of type 'void' is not assignable to parameter of type 'Function'
So, i don't know what is the problem and what should i do.
Share Improve this question asked Oct 16, 2017 at 12:24 Hely Saul ObertoHely Saul Oberto 5971 gold badge11 silver badges23 bronze badges 1-
You are passing the value returned by calling
this.changea(this)
and the value ofthis.changer
. What are they? BTW, "void" is not an ECMAScript Type. – RobG Commented Oct 16, 2017 at 12:32
1 Answer
Reset to default 6The second argument you are passing is this.changea(this)
- the result of this is that you are passing the return value of te changea
function, not the function itself.
If you want to pass a function as the argument, and preserve the meaning of this
, you can use:
modalshow = new Confirmation(false, () => this.changea(this), this.changer);
You have now wrapped your code in a function, that hasn't yet been executed.