1

Below is Typescript code. I don't understand what is a type of params parameter?

export class SomeService {
    ...
    public subscribe<T>(params: { new(...args: any[]): T }): Observable<T> {

        ...
    }
    ...
}

Can someone explain to me what this part means { new(...args: any[]): T }?

UPDATE:

params has to be Type. Here is an example

Like this: someService.subscribe(String); or someService.subscribe(SomeClass);

AntonIva
  • 597
  • 1
  • 6
  • 22
  • @rlemon, thanks. The link is not that clear for a newbie like me. But link inside the link is very clear: https://stackoverflow.com/questions/38311672/generic-and-typeof-t-in-the-parameters/38311757#38311757 – AntonIva Oct 30 '18 at 17:20
  • Every line of typescript code I see makes me hate it more. I consider that completely unreadable. – connexo Nov 06 '18 at 20:34

1 Answers1

0

I think that is telling you that params must be constructible by any number of parameters, which becomes a T.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445