在此链接中:创建商店的https://mobx-react.js.org/recipes-context第10行有:
friends: [] as TFriend[],
这是什么意思?这是Javascript,还是专门用于MobX?
开始时有:
export type TFriend = { name: string isFavorite: boolean isSingle: boolean }
为什么需要调用好友数组作为导出类型?
此行是打字稿行=> docs
'as'是casting的推荐语法。所以代码行等效于:
friends: <TFriend[]> []