2016-06-07 27 views
3

說一個打字稿財產我有2個接口:如何聲明實現多個接口

interface Interface1{} 
interface Interface2{} 

是有申報財產爲實現這兩個接口的方法嗎?喜歡的東西:

class MyClass{ 
    public p: Interface1, Interface2 
} 

回答

0
interface Interface1 { } 
interface Interface2 { } 
interface ICombination extends Interface1, Interface2 { }; 
class MyClass { 
    public p: ICombination 
} 
+0

這工作得很好,但缺點是,由於接口數量的增加,組合的數量非常快速增長所覆蓋。根據使用情況,這可能不成問題,但需要考慮。 – Tim