In TypeScript, I have defined the following interfaces and classes:
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;
}
My goal is to implement PageAdapter<Page<T>>
.
The attempted implementation resulted in 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']);
}
}
Replacing Page
with Page<T>
in the first line did not work at all.
I am seeking guidance on how to properly implement this. Any help would be greatly appreciated.
Thank you,