I've come across the following type annotation on a function parameter:
typeFilter : new(...args) => T
where T
is a generic parameter on the function.
What does new(...args)
mean in this context, and where is it documented?
TL;DR new(...args) => T
represents constructor of T
taking any parameters.
new
describes "static" part of a class/function, meaning it is a constructor and consumer can create new instance of T
using new
keyword. Example here.
As for ...args
- these are rest parameters
Rest parameters are treated as a boundless number of optional parameters. When passing arguments for a rest parameter, you can use as many as you want; you can even pass none
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With