I want to build an function which takes any object and return that object with few added properties. Something like:
//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()
For the above code typescript compiler return the error that an interface can only add a class or interface, how I can express this in typescript.