I am working on creating a dynamic table that can change its content and position based on a special row unique to each page.
Currently, I'm encountering an error
The generic type 'Table<SpecialFunctions>' requires 1 type argument(s).ts(2314)
when classes are extending the abstract Table class.
I have realized that in an abstract class, the child classes' getSpecialFunctions() method should return SpecialFunctions. How can I make this method return a specific type for each individual child class?
abstract class Table<SpecialFunctions> {
constructor() {}
loadData() {}
showTable() {}
updateCell() {}
abstract getSpecialFunctions(): SpecialFunctions;
}
class DoneWorksPageTable extends Table {
getSpecialFunctions(): TypeForSpecialRowOnDoneWorksPage{
return {
text: "test",
addNewDoneWork: () => console.log("test done work class"),
};
}
}
class InformationPageTable extends Table {
getSpecialFunctions(): TypeForSpecialRowOnInformationPage{
return {
toLoad: ["file", "table", "text", "image"],
addNewInfo: () => console.log("test info class"),
};
}
}