Open rotu opened 9 months ago
@ahejlsberg any thoughts? Seems straightforward enough?
Can we get this for calling the function directly also? That is: just support empty type argument lists for generic functions, if all of the type parameters have defaults. It would be weird for (f<>)()
to work but for f<>()
not to work.
π Search Terms
instantiation expression, empty, type arguments
β Viability Checklist
β Suggestion
I would like to be able to instantiate a generic function type with an empty type arguments list.
It would be nice to allow this for generic types, but it's not as necessary, since a generic type is always instantiated in a type context, even if no type arguments list is given. A generic function type needs to be specifically instantiated.
π Motivating Example
Here is a generic function where a type parameter has a default. I can get use an instantiation expression to specialize it to a non-generic function.
Here is a generic function with only one type parameter. I cannot use an instantiation expression with the default for
S
:π» Use Cases
Originally mentioned here: https://github.com/microsoft/TypeScript/issues/57463#issuecomment-1957739330