I want to add the extension method format() to String . Therefore, I expect that I can use String.format wherever in my project. I followed the recommendation of this topic , but it does not help. I got this error: 
Can anybody help me?
Thanks in advance.
ps: I want to add an extension method, as I did in angular 1.xx

Edit
use declare global will not receive an error.
declare global { interface String { format(): string; }} String.prototype.format = function () :string { var result = arguments[0]; for (var i = 0; i < arguments.length - 1; i++) { var reg = new RegExp("\\{" + i + "\\}", "gm"); result = result.replace(reg, arguments[i + 1]); } return result;}
How do we use String.format('<img alt="{0}" title="{0}" src="{1}" />', name, id); Since format does not require parameters
angular extension-methods typescript
jack.pop
source share