Within my codebase, I have created an abstract class:
export abstract class Filters<P> {
protected field: string;
protected constructor(field: string) {
this.field = field;
}
protected abstract getFilter(): P;
}
Additionally, there is an interface defined as follows:
interface IRagne<T> {
field: string;
from: T;
to: T;
}
To implement the abstract Filters class, I have a specific class called RangeFilter:
class RangeFilter<T, P = IRagne<T>> extends Filters<P> {
private from: T;
private to: T;
constructor(field: string, from: T, to: T) {
super(field);
this.from = from;
this.to = to;
}
getFilter(): P {
return {
field: super.field,
from: this.from,
to: this.to
};
}
}
However, my integrated development environment displays an error in the getFilter
implementation. It suggests using getFilter(): IRange<T>
, but this solution does not resolve the issue.