I am trying to figure out how to read the following syntax:
type Bob<T extends Alice = Alice> = ....
I understand up to extends which means that the supplied type is constrained by Alice. But what does the assignment after that mean?
Reading through TS docs and googling the problem I haven't been able to find anything to explain that, probably because I don't know what to search for.
That's a default type argument. For generic types like Bob
, it means you can leave out a type argument and the type checker will use the default. So you can write Bob<Carol>
and get Bob<Carol>
, but if you just write Bob
you get Bob<Alice>
. Without a default argument you'd have to write out Bob<Alice>
explicitly.