已声明ValidationContext,但从不读取其值?

时间:2018-06-23 00:57:30

标签: typescript

我有以下内容:

    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

知道这意味着什么吗?

1 个答案:

答案 0 :(得分:1)

您必须使用括号将箭头函数的键入参数括起来

validators.forEach((vc:ValidationContext) => {
    vc.validate(value);
});