0

I have a component defined as :

type myType = anotherType<weirdType1, weirdType2, weirdType3>;

function weirdComponent({q}: myType)

And it's called like: <weirdComponent {...myVar} />, where myVar is an isinstance of myType.

  • What does {q} mean inside weirdComponent function signature

  • What does {...myVar} do?

  • What kind of type is myType ?

jonrsharpe
  • 107,083
  • 22
  • 201
  • 376
user1008636
  • 2,469
  • 10
  • 26
  • 40
  • You've asked several questions. `{q}` is parameter destructuring. `{...myVar}` is prop spreading. *"what kind of type is `myType`"* - it's the type whose definition is shown on the previous line, what do you mean *"what kind of type"*? – jonrsharpe Jun 04 '20 at 20:56
  • Title question is a dupe of https://stackoverflow.com/q/31048953/3001761. First one in the body dupes https://stackoverflow.com/q/10804982/3001761. Third one I don't know what you're asking. I'd recommend bookmarking https://stackoverflow.com/questions/9549780/what-does-this-symbol-mean-in-javascript. – jonrsharpe Jun 04 '20 at 20:57

1 Answers1

0

What does {q} mean inside weirdComponent function signature

Its argument destructuring.

What does {...myVar} do?

Its spreading attributes

What kind of type is myType ?

Its anotherType<weirdType1, weirdType2, weirdType3>;. You can hover over it to view the details.

basarat
  • 234,454
  • 52
  • 420
  • 492