简体   繁体   English

T缺少类型注释

[英]Missing type annotation for `T`

I am trying to build code with simple javascript function below: 我正在尝试使用以下简单的javascript函数构建代码:

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

But I am getting below error: 但我得到以下错误:

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]

I am using flow and building using npm. 我正在使用流,并使用npm构建。

This error says your annotation is missing. 此错误表明您的注释丢失。 Add return type annotation to function 向函数添加返回类型注释

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

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 流程Javascript“ T的缺少类型注释”和“ S的缺少类型注释” - Flow Javascript “Missing type annotation for T” And “Missing type annotation for S” HOC:函数调用的类型参数“ Props”。 缺少注释 - HOC: type parameter `Props` of function call. Missing annotation 使用带有ImmutableJs记录的流 - 缺少“值”的类型注释 - Using Flow with ImmutableJs Record - Missing type annotation for `Values` 配置 Flow 以忽略 React Native 上的“Missing type annotation for ...”错误 - Configure Flow to ignore "Missing type annotation for ..." errors on React Native 缺少在函数类型中声明的类型参数的类型注释,该类型参数是在调用CombineReducers时隐式实例化的 - Missing type annotation for a type parameter declared in function type that was implicitly instantiated at call of combineReducers “解构(缺少注释)”来源:“流” - 'destructuring (Missing annotation)' source: 'flow' @JavaScript没有注释类型 - @JavaScript is no annotation type 子类工厂的类型注释 - Type annotation for subclass factory 类型注释,用于转换为空性 - Type annotation for converting nullability 在Typescript中为`this`关键字键入注释 - Type annotation for `this` keyword in Typescript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM