Here is a snippet of code that I am working with:
public getProducts<T>(): Observable<T[]> {
return this.httpClient
.get<T[]>(this.baseUrl + '/users')
.pipe(
map((entities) => {
return entities.map((entity) => {
return new T(entity);
})
}),
catchError((err) => Observable.throw(err))
);
}
I encountered an issue with this line: return new T(entity)
;
Can anyone provide guidance on how to instantiate a generic type constructor in TypeScript?