Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug/Question] Cross tables typing #185

Open
Xaz16 opened this issue Oct 15, 2020 · 2 comments
Open

[Bug/Question] Cross tables typing #185

Xaz16 opened this issue Oct 15, 2020 · 2 comments
Labels
support request Questions or issues with implementation

Comments

@Xaz16
Copy link

Xaz16 commented Oct 15, 2020

Problem:

This code snippet produce such error from Typescript:

const resultTable = new Table({
  head: ['', 'Assets ', 'Entries']
});

resultTable.push(
   { 'Previous values': [`100`, `200`] },
   { 'Normalized values': [`10`, `100`] }
);
Type 'string[]' is not assignable to type '(string & Cell[]) | (number & Cell[]) | (false & Cell[]) | (true & Cell[]) | (CellOptions & Cell[])'.
  Type 'string[]' is not assignable to type 'CellOptions & Cell[]'.
    Property 'content' is missing in type 'string[]' but required in type 'CellOptions'.ts(2322)

According to the documentation about cross table this code should be absolutely valid https://github.com/cli-table/cli-table3#cross-tables.

Could you check the typing for that case or maybe I'm wrong?

Environment

Typescript: 3.8.3
cli-table3: 0.6.0

@speedytwenty speedytwenty added the support request Questions or issues with implementation label Mar 27, 2022
@speedytwenty
Copy link
Collaborator

speedytwenty commented Mar 27, 2022

From the syntax in your table, it seems your table is not correct. Each row pushed into the table is expected to be an array of cells. You're pushing objects into the table.

Try this instead:

resultTable.push(
   ['Previous values:', 100, 200],
   ['Normalized values:', 10, 100],
);

@speedytwenty
Copy link
Collaborator

I wasn't aware of the "cross-table" syntax option mentioned here: https://github.com/cli-table/cli-table3#cross-tables

Reopening. I'll take another poke at this now that my incorrect assumption is corrected.

@speedytwenty speedytwenty reopened this Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support request Questions or issues with implementation
Projects
None yet
Development

No branches or pull requests

2 participants