Open PenguRinPrivate opened 2 years ago
Hi @PenguRin, how about reuse the table body content somehow? Btw, a sample code would help so much. Thanks.
Hey @nam-hle, reusing the content is not an option as they have different use cases but the same table layout. All that'd change would literally be the content in like 5 cases. To make the use case more clear with an example:
config.header.content = 'xyz'
console.log(table(commandTable, config));
This is the desired outcome without resolving to @ts-ignore or creating multiple configuration files.
Thank you!
Hey @PenguRin, thanks for clarification. What if we have a function like this:
function createTable(title: string, data: string[][]) {
const config: TableUserConfig = {
columnDefault: {
width: 10,
},
header: {
alignment: 'center',
content: title,
},
}
return table(data, config)
}
Of course that works but as aforementioned, I basically don't see the point of factory functions or any hacky workarounds when we could simply access it, there should be no harm, right?
Unless I am missing something fundamental here that justifies the readonly
property.
Right now it's on readonly mode if you assign the
TableUserConfig
to your config file, however, this prevents reusability if you want to change the content only for another table. Right now I have to either @ts-ignore the config file input if I want to change the content without assigning a type to it or I have to create a completely new config file.