Asp.net mvc ';参数';对象不能在ES3和ES5中的箭头函数中引用。考虑使用标准函数表达式
目前正在构建一个示例白板项目,并面临一个类型脚本问题Asp.net mvc ';参数';对象不能在ES3和ES5中的箭头函数中引用。考虑使用标准函数表达式,asp.net-mvc,typescript,arrow-functions,Asp.net Mvc,Typescript,Arrow Functions,目前正在构建一个示例白板项目,并面临一个类型脚本问题 var format = (formatString, ...params: any[]): string => { var i = 0; while (/%s/.test(formatString)) { formatString = formatString.replace('%s', arguments[++i]) --> Error at (arguments) } r
var format = (formatString, ...params: any[]): string => {
var i = 0;
while (/%s/.test(formatString)) {
formatString = formatString.replace('%s', arguments[++i]) --> Error at (arguments)
}
return formatString;
};
我检查了关于堆栈溢出的类似问题,但没有得到具体的答案您混淆了JS中rest参数功能的可用性 对象用于ES3和ES5中参数数量可变的函数这一事实不应使您在typescript中使用它 对于typescript中参数数量可变的函数,应使用。Typescript编译器将其编译为:
- 与ES2015目标一致
- 带有ES3或ES5目标的参数对象
请帮助我了解您的
.tsconfig
es目标是什么?
var format = (formatString: string, ...params: any[]): string => {
var i = 0;
while (/%s/.test(formatString)) {
formatString = formatString.replace('%s', params[i++]);
}
return formatString;
};