2
我將以下格式函數定義爲String。 這工作正常,但問題是webstorm標記爲「String.prototype.format」紅色。 如何抑制錯誤?Webstorm IDE中的Typescript字符串原型顯示錯誤
interface String {
format(variables:Array<string>):string
}
String.prototype.format = (variables:Array<string>):string => {
return this.replace(/%(\d+)/g, function(_,m) {
return variables[--m];
});
};
感謝