TypeScript · Middle · Pytanie 63 z 75
Jak uzyskać typ instancji i argumenty konstruktora klasy?
type Svc = InstanceType<typeof ApiService>;
type Args = ConstructorParameters<typeof ApiService>;- ✓Poprawna odpowiedź: Przez
InstanceTypeiConstructorParameterszastosowane dotypeof Class - 2Przez
ReturnType<ApiService> - 3Klas nie można używać w operatorach typów
Wyjaśnienie
ApiService jako typ oznacza już typ instancji; typeof ApiService to sam konstruktor.