0
点赞
收藏
分享

微信扫一扫

Ts数组遍历报错:this expression is not callable


我在定义数组的时候,将其定义为:

export interface demo {
count: number;
rows: demo1[] | demo2[] | demo3[];
}

对rows使用map方法

demo.rows.map(....)

会报错:


app/common/utils/asset.ts:598:14 - error TS2349: This expression is not callable.
Each member of the union type ‘((callbackfn: (value: IssueRowsItem, index: number, array: IssueRowsItem[]) => U, thisArg?: any) => U[]) | ((callbackfn: (value: Codebase, index: number, array: Codebase[]) => U, thisArg?: any) => U[]) | … 4 more … | ((callbackfn: (value: Dependency, index: number, array: Dependency[]) => U, thisArg?: a…’ has signatures, but none of those signatures are compatible with each other.
Ts数组遍历报错:this expression is not callable_数组


解决方法:

将数组解构到新数组后遍历

[...demo.rows].map(....)



举报

相关推荐

0 条评论