【发布时间】:2021-03-21 17:21:20
【问题描述】:
当我尝试将正确的类型传递给内置 .map 和 .filter 函数时,我的 TS 代码出现错误
当我这样做时:Object.values(league.games).map((game: Game) => { 我明白了
Argument of type '(game: Game) => { players: { rounds: PlayerRound[]; information: PlayerInformation; hasBeenEliminated: boolean; }[]; complete: boolean; id: string; leagueRound: number; }' is not assignable to parameter of type '(value: unknown, index: number, array: unknown[]) => { players: { rounds: PlayerRound[]; information: PlayerInformation; hasBeenEliminated: boolean; }[]; complete: boolean; id: string; leagueRound: number; }'.
Types of parameters 'game' and 'value' are incompatible.
但我不明白如何正确地给它正确的类型?我对它的要求有点困惑
我该如何解决这个问题?
【问题讨论】:
标签: javascript reactjs typescript types