Actually, I am currently thinking of creating an extension method to all the object or reference that are created in my component
I know how to create an extension method in typeScript but I am not able to get what I want to use an interface to get the behavior I wanted.
I tried using the Object in the interface but it won't work
MyExtension Method : extension.model.ts
declare global {
interface Object {
thousandsSeperator(): String;
}
}
Object.prototype.thousandsSeperator = function(): string {
return Number(this).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
export {};
// this is just a simple extension method
Now, whenever if someone tries to create an object of class or reference of an interface then, they should get the extension method I created.
// Object
Object1 = new MyComponentClass();
// Reference
Object2: MyComponentClass;
this.Object1.thousandsSeperator();
this.Object2.thousandsSeperator();