I am currently working on developing a base class called AbstractQuery
, which will serve as a parent class to other classes that inherit from it. The goal is to override certain methods within the child classes.
class AbstractQuery {
public before<A, S>(context: Context<A>, args: A, source?: S): Promise<A> {
return Promise.resolve(args);
}
}
My intention now is to customize the AbstractQuery::before
method in one of my child classes:
class FindBookByIdQuery extends AbstractQuery {
public before(context: Context<arguments.ID>, args: arguments.ID): Promise<arguments.ID> {
this.log.debug('hook before args', args);
return Promise.resolve(args);
}
}
However, I encounter an error message:
[ts] Property 'before' in type 'FindBookByIdQuery' cannot be assigned to the same property in the base type 'AbstractQuery'. Type '(context: Context, args: ID) => Promise' cannot be assigned to type '(context: Context, args: A, source?: S) => Promise'. Parameters 'context' and 'context' have incompatible types. Type 'Context' is not compatible with type 'Context'. Type 'A' cannot be assigned to type 'ID'. [2416]