I've created a class that can take JSON objects and transform them into the desired class. Here's the code:
import {plainToClass} from "class-transformer";
import UserDto from "../../auth/dto/user.dto";
class JsonConverter {
convertData(data) {
return plainToClass(UserDto, data);
}
}
However, when I try to make the class more generic,
import {plainToClass} from "class-transformer";
import UserDto from "../../auth/dto/user.dto";
class JsonConverter<T> {
convertData(data) {
return plainToClass(T, data);
}
}
I encounter the following error:
T only refers to a type, but is being used as a value here