天天看點

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(....)