在"Typescript extend String Static"後擴展陣列
interface StringConstructor {
isNullOrEmpty(str:string):boolean;
}
String.isNullOrEmpty = (str:string) => !str;
它確實工作。但對於通用接口,我遇到了問題。例如,我需要在Array中添加新的方法contains()。我使用下面的代碼:
//1
interface Array<T> {
contain(item: T): boolean;
}
//2
?????? = (item: T) => {
// ....
return true;
};
第一步後,在VS智能感知,並彈出包含的方法,但在那裏我可以做的實現方法?
可能重複[擴展數組在TypeScript](http://stackoverflow.com/questions/12802383/extending-array-in-typescript) –