Reputation: 1
I am having an issue creating a prototype in TypeScript, when I use the method I get "TypeError: t.stringTesting is not a function"
below is the code.
extensions.ts
interface String {
stringTesting() : string;
}
String.prototype.stringTesting = function (): string {
return "testing"
}
in my Angular2 component I am using
var t: string = "";
t = t.stringTesting();
alert(t);
Upvotes: 0
Views: 79
Reputation: 275849
t.stringTesting is not a function"
You need to make sure the extensions.js
runs before any code that uses it.
Upvotes: 1