通用扩展接口我想建立一个功能女巫采取任何对象,并返回该对象很少添加的属性。是这样的:在打字稿
//this code doesn't work
function addProperties<T>(object: T): IPropertiesToAdd<T> {/*implmentions code*/};
interface IPropertiesToAdd<T> extend T{
on(): void;
off(): void;
}
//usage example
var str = new String('Hello')
addProperties(str)
str.charAt(3)
str.on()
上面的代码编译打字稿返回错误的接口只能添加一个类或接口,我怎么能在打字稿表达这一点。
感谢您的时间,在架构变化不大,你的答案真的帮助。 – user2692945 2014-10-30 14:26:30