T缺少类型注释

时间:2019-04-17 10:18:26

标签: javascript node.js npm flowtype

我正在尝试使用以下简单的javascript函数构建代码:

filterArray(user: any, items: Array<Object>) {
    items = items.filter(item => {return true;});
    return items;
}

但是我遇到了以下错误:

Missing type annotation for `T`. `T` is a type parameter declared in array type [1] and was implicitly instantiated at
call of method `filter` [2].

   src/mod/test.js:69:15
   69|       items = items.filter(item => {return true;});
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2]

References:
   src/mod/test.js:69:15
   69|       items = items.filter(item => {return true;});
                     ^^^^^ [1]

我正在使用flow并使用npm进行构建。

1 个答案:

答案 0 :(得分:1)

此错误表明您的注释缺失。向函数添加返回类型注释

function add(x: number, y: number): number {
return x + y;

}

相关问题