[英]migrating function to typescript from JS
I am implementing a working JS function to typescript, but I'm getting an error on parameters: "error, success" 我正在为typescript实现一个有效的JS函数,但是我在参数上遇到错误:“错误,成功”
[tslint] Parentheses are required around the parameters of an arrow function definition (arrow-parens)
[tslint]围绕箭头函数定义的参数需要括号(arrow-parens)
function chapa() {
console.log('altered');
TouchID.isSupported()
.then(authenticate)
.catch(error => {
AlertIOS.alert('TouchID not supported');
});
}
so the "error" is underlined with error, with this message: 所以“错误”带有错误的下划线,并显示以下消息:
[tslint] Parentheses are required around the parameters of an arrow function definition (arrow-parens)
[tslint]围绕箭头函数定义的参数需要括号(arrow-parens)
how should I pass then the "error" parameter?, cheers 我该如何传递“错误”参数?,欢呼
就像它说的那样,在参数周围加上括号:
.catch((error: any) => {
If you'd rather not add parentheses around the parameter (it's not strictly required by Typescript), add the following to the rules
object in your tslint.json file. 如果您不想在参数周围添加括号(Typescript不严格要求),请将以下内容添加到tslint.json文件中的
rules
对象中。
"arrow-parens": [true, "ban-single-arg-parens"]
Check out https://palantir.github.io/tslint/usage/configuration/ and https://palantir.github.io/tslint/rules/arrow-parens/ for more details. 有关详细信息, 请查看https://palantir.github.io/tslint/usage/configuration/和https://palantir.github.io/tslint/rules/arrow-parens/ 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.