我正在定义下面的Typescript接口。 clickCustomButton1应该不会返回任何内容,但我不知道如何指定。后来如何为函数定义一个Typescript接口?
clickCustomButton1: null
然后:
interface IButtonTemplate {
clickCustomButton1:(); // How can I say this should return nothing?
// more code here
}
我用这个在我的代码是这样
newTopicTests =() => {
}
clickCustomButton1 = this.newTopicTests();
它给了我一个错误说:
Error 2 Cannot convert 'void' to '() => boolean'
能有人给我知道我做错了什么?我想我需要做的是指定clickCustomButton1以及newTopicTests不返回任何东西。但是我怎么能用Typescript来做到这一点?
user2864740 - 我很抱歉,但我不确定我的理解是什么意思。我在我的问题中添加了一行,询问是否有人可以告诉我如何做到这一点,并在分配给clickCustomButton1的任何内容符合不返回任何内容的条件时使其工作。 – 2014-09-26 10:14:25