Let's say I have a function called foo
defined in a "util.ts" file and I add it to the String
prototype like this:
if (Object.getOwnPropertyNames(String.prototype).indexOf("foo") == -1) {
Object.defineProperty(String.prototype, "foo", { value: method, enumerable: false });
}
The issue is that if I generate ".d.ts" file automatically with "tsc", this function won't be marked as a method of the String
prototype, so I won't be able to use it in "TypeScript" like this:
import { foo } from "..."
let str: string = "Foo";
str.foo();
Is there of way of achieve that without manually creating the ".d.ts" (I actually don't even know how to achieve that manually).
Thanks