0

In this link: https://mobx-react.js.org/recipes-context line 10 of the create store there is:

 friends: [] as TFriend[],

What does this mean? Is this Javascript or is this specifically for MobX?

In the beginning theres:

export type TFriend = {
  name: string
  isFavorite: boolean
  isSingle: boolean
}

Why is there a need to call friends an array as the export type?

hellomello
  • 8,219
  • 39
  • 151
  • 297

1 Answers1

0

this line is a typescript line => docs

'as' is the recommended syntax for casting in typescript. so the line of code is equivalent to:

friends: <TFriend[]> [] 
ettakhi
  • 177
  • 1
  • 7