I am facing an issue with the following code snippet:
class Table {
get pagination () {
return {
get item () {
return {
log (s : string) {
console.log(s);
}
}
}
}
}
}
class TableWithFirst extends Table {
get pagination () {
return {
...super.pagination,
get first () {
this.item.log("first");
return "first";
}
}
}
}
const t = new TableWithFirst();
t.pagination.first
After running the code, I encountered the error message:
[ERR]: "Executed JavaScript Failed:"
[ERR]: Cannot read properties of undefined (reading 'log')
What is the best way to include the first
getter in the pagination
section without errors? Do I need to refactor the logic into a separate class?