Let's reduce the type to smaller, bite size pieces that are more easily understood and then build back up to the full thing.
First, let's drop the new
from our mind and focus on the latter part of the definition:
(...args: any[]) => any
Next let's forget about the arguments for now:
() => any
Hopefully this is familiar as a function that returns type any
.
Next we can add back in the args:
(...args: any[]) => any
...args: any[]
is using the Rest Parameters construct which essentially says that there can be any number of parameters of the provided type any
. Because there are an unknown amount of any
parameters, the type of the argument is an array of any
.
So hopefully now it makes sense that this is a function that accepts any amount of arguments (of type any
) and returns type any
.
Finally we can add back the new
keyword to get:
new (...args: any[]) => any
The new
keyword here specifies that this function can be treated as a class constructor function and called with the new
keyword.
This gives us the whole picture that the function is a function that accepts any amount of arguments (of type any
) that returns type any
and can be used as a constructor function with the new
keyword.
When taken in the context of the API, it is essentially allowing you to pass any class constructor to the function.