我正在定義下面的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