You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I only read the function signature at first and wondered how T["parent"] is valid TS. After all, T could be any type, so there might not be a parent field. Only after looking at the Type Parameters section did I see the constraint.
So I wanted to ask whether this was intentional.
I can see the appeal of saving precious screen space, but generic constraints can be necessary for the signature to make sense.
The text was updated successfully, but these errors were encountered:
This is intentional, I'm not sure how much I agree with it though, it was a decision made before I started maintaining typedoc... could argue that if that type is omitted, shouldn't parameters be as well?
I just thought that this might be a problem for function overloads. What if 2 functions overloads most meaningfully differ in constraints of their type parameters? Example:
If typedoc only displays the following, then it'll be quite confusing to readers.
foo<T>(arg: T): `${T}!`
foo<T>(arg: T): T
Of course, those are edge cases. I don't know whether making them unambiguous is worth the screen space. The type of constraints might be quite long, and signatures can get very long even without them.
Search terms
function signature, generic constraints, extends
Question
I recently updated to 0.24.1 and noticed this:
I only read the function signature at first and wondered how
T["parent"]
is valid TS. After all,T
could be any type, so there might not be aparent
field. Only after looking at the Type Parameters section did I see the constraint.So I wanted to ask whether this was intentional.
I can see the appeal of saving precious screen space, but generic constraints can be necessary for the signature to make sense.
The text was updated successfully, but these errors were encountered: