I want to extends a native javascript type in typescript. This is possible using an interface to declare extended properties. But how to declare overloaded properties ?
interface HTMLElement {
add:(a:string)=>void; // error: add is duplicate
add:(a:boolean)=>void;
}
HTMLElement.prototype.add = function (a):void{
if(typeof a=="string"){
}
else if(typeof a=="boolean"){
}
}
class HTMLElement2 {
add(a:string):void; // ok
add(a:boolean):void;
add(a):void{
if(typeof a=="string"){
}
else if(typeof a=="boolean"){
}
}
}
Thank you