Experiencing an issue where I need to create an abstract class that can connect to the appropriate repository based on the initialization type T. However, there is a challenge in calling the value of T instead of the type as a parameter for the getRepository method from the typeorm package.
import {getDataSource} from "../utils/data-source";
import {Category} from "../model/category";
import {EntityTarget, ObjectLiteral} from "typeorm";
export abstract class Controller<T> {
protected repository;
public init = async () => {
this.repository = (await getDataSource()).getRepository(T);
};
}
The line 'getRepository(T);' presents the mentioned problem in the title.