I have a family of three classes:
abstract class Form {
protected async submit({ url: string, data: any }): Promise<void> {
// submit data from form
}
}
abstract class BookForm extends Form {
public name?: string;
public abstract async submit(): Promise<void>
}
class UpdateBookForm extends BookForm {
private id: string;
public async submit(): Promise<void> {
// Abstract method 'submit' in class 'BookForm' cannot be accessed via super expression.
return super.submit({
url: '/book/update',
data: {
id: this.id,
name: this.name,
}
});
}
constructor(bookId: string) {
super()
this.id = bookId;
}
}
I'm getting an error when trying to access the super.submit() method from UpdateBookForm.
Abstract method 'submit' in class 'BookForm' cannot be accessed via super expression.
What I'm trying to achieve is that BookForm is aware of its derivatives containing method submit(), without any implementation in BookForm.
Any suggestions on how to accomplish this? Maybe I can access the grandparent directly (super.super?) from UpdateBookForm?