ReturnType
extracts return type of a function.
Is there a way to define ArgumentsType
that extracts parameter types of a
I'm sure there are many uses for Parameters
but I wanted a way to provide proxy method to the same method on a private member and it seemed a perfect fit.
eg. I want to have the following, such that if the authService.login
signature changes I don't have to modify my proxy - just whatever is calling it.
login(username: string, password: string) { this.authService.login(username, password); }
With Parameters
you can do the following
login = (...params: Parameters) => this.authService.login(...params);
Of course the benefit is that if you have complex parameters it'll just take care of itself nicely - (probably wouldn't recommend this for just two strings!)
It took me a couple attempts to figure out that I needed ...
on both occurrences of params
.