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
In a nutshell, the type of a rest parameter can now be a tuple.
Previously we said rest parameters could only be arrays.
What this means is that an n-tuple-trailed rest parameter (i.e. (arg0: boolean, ...args: [number, string])) is the same as having n trailing parameters (i.e. (arg0: boolean, arg1: number, arg2: string)).
Because we need to encode everything that parameter lists have, we need a few things: empty length, optionality and open-endedness parameters
Now have an empty tuple types.
Also now allowing tuple elements to be optional using ?.
Means that the length becomes a union of
Is the ? part of the type?
No, it's a modifier for tuple elements
We said last week we'd be okay giving the syntax up for this case.
In that context.
And plus, we already recognize this in JSDoc anyway, so we've already effectively given it up.
Rest args mean we need open-ended tuples.
Currently can't operate on generic type argument lists.
All methods are generic on the called function (they use a this parameter to infer the parameter types of the functions themselves.)
Can Function itself just be made generic instead of doing this?
Well, doesn't work with overloads.
Well there are just going to be things that don't work.
Rest parameters and tuple types
#24897
In a nutshell, the type of a rest parameter can now be a tuple.
(arg0: boolean, ...args: [number, string])
) is the same as having n trailing parameters (i.e.(arg0: boolean, arg1: number, arg2: string)
).Because we need to encode everything that parameter lists have, we need a few things: empty length, optionality and open-endedness parameters
?
.?
part of the type?Currently can't operate on generic type argument lists.
All methods are generic on the called function (they use a
this
parameter to infer the parameter types of the functions themselves.)Function
itself just be made generic instead of doing this?What doesn't work?
Inferring from a generic argument list:
Conditional type relationships
#24821
extends
check.false
branch, this PR builds up negated constraints.T extends T ? ... : ...
More conditional type relationships
#22735
#24929
#23541
Also, how far do you want to go?
function
The text was updated successfully, but these errors were encountered: