Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc ';参数';对象不能在ES3和ES5中的箭头函数中引用。考虑使用标准函数表达式_Asp.net Mvc_Typescript_Arrow Functions - Fatal编程技术网

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;
};