class-transformer icon indicating copy to clipboard operation
class-transformer copied to clipboard

question: Is generic type conversion possible ?

Open sinanakyazici opened this issue 3 years ago • 0 comments

Hello,

I have a class like below,

export default class PageList<T = BaseModel> {
    items: T[];
    totalCount: number;
    pageIndex: number;
    indexFrom?: number;
    pageSize?: number;
    totalPages?: number;
    hasPreviousPage?: boolean;
    hasNextPage?: boolean;
}

I want to gain an object that has type is PageList<TempModel>. I try this. plainToInstance(PageList<TempModel>, response,{ enableImplicitConversion: true });

But It gives an error. I tried this @Type(() => T) but I didn't work.

sinanakyazici avatar Feb 26 '22 10:02 sinanakyazici