我有以下内容:
const validators:Array<ValidationContext> =
ValidationContainer.getValidationContexts(key);
const value:any = o[propertyName];
到目前为止,一切都很好。没有错误。现在,我要像这样遍历validators
数组:
validators.forEach(vc:ValidationContext => {
vc.validate(value);
});
VSCode提供以下错误:
[ts] 'ValidationContext' is declared but its value is never read.
[ts] Parameter 'ValidationContext' implicitly has an 'any' type.
(parameter) ValidationContext: any
知道这意味着什么吗?
答案 0 :(得分:1)
您必须使用括号将箭头函数的键入参数括起来
validators.forEach((vc:ValidationContext) => {
vc.validate(value);
});