I have the following interfaces and classes in TypeScript:
export interface PageInterface<T> {
count: number;
previous: string;
next: string;
results: T[];
}
export class Page<T> implements PageInterface<T> {}
----------------------------------------------------------
export interface AdapterInterface<T> {
adapt(item: any): T;
}
And I need to implement PageAdapter<Page<T>>.
Is it possible? I've tried the following but ended up with errors (Type 'Page' si not generic):
export class PageAdapter<Page> implements AdapterInterface<Page> {
adapt(item: any): Page<T> {
return new Page<T>(item['count'], item['previous'], item['next'], item['results']);
}
}
If I put Page<T> instead of Page in the first line, it doesn't work at all.
How can i implement this?
Many thanks,