admin 管理员组文章数量: 1086019
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.
版权声明:本文标题:javascript - Argument of type 'void' is not assignable to parameter of type 'Function' - Stack O 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744085687a2531081.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论