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

SpanningCells API example causes TS error #212

Closed
tomhoad opened this issue Oct 7, 2022 · 2 comments
Closed

SpanningCells API example causes TS error #212

tomhoad opened this issue Oct 7, 2022 · 2 comments

Comments

@tomhoad
Copy link

tomhoad commented Oct 7, 2022

const data = [
  ['Test Coverage Report', '', '', '', '', ''],
  ['Module', 'Component', 'Test Cases', 'Failures', 'Durations', 'Success Rate'],
  ['Services', 'User', '50', '30', '3m 7s', '60.0%'],
  ['', 'Payment', '100', '80', '7m 15s', '80.0%'],
  ['Subtotal', '', '150', '110', '10m 22s', '73.3%'],
  ['Controllers', 'User', '24', '18', '1m 30s', '75.0%'],
  ['', 'Payment', '30', '24', '50s', '80.0%'],
  ['Subtotal', '', '54', '42', '2m 20s', '77.8%'],
  ['Total', '', '204', '152', '12m 42s', '74.5%'],
];

const config = {
  columns: [
    { alignment: 'center', width: 12 },
    { alignment: 'center', width: 10 },
    { alignment: 'right' },
    { alignment: 'right' },
    { alignment: 'right' },
    { alignment: 'right' }
  ],
  spanningCells: [
    { col: 0, row: 0, colSpan: 6 },
    { col: 0, row: 2, rowSpan: 2, verticalAlignment: 'middle'},
    { col: 0, row: 4, colSpan: 2, alignment: 'right'},
    { col: 0, row: 5, rowSpan: 2, verticalAlignment: 'middle'},
    { col: 0, row: 7, colSpan: 2, alignment: 'right' },
    { col: 0, row: 8, colSpan: 2, alignment: 'right' }
  ],
};

console.log(table(data, config));

Throw the TS error:

TS2345: Argument of type '{ columns: ({ alignment: string; width: number; } | { alignment: string; width?: undefined; })[]; spanningCells: ({ col: number; row: number; colSpan: number; rowSpan?: undefined; verticalAlignment?: undefined; alignment?: undefined; } | { ...; } | { ...; })[]; }' is not assignable to parameter of type 'TableUserConfig'.   Type '{ columns: ({ alignment: string; width: number; } | { alignment: string; width?: undefined; })[]; spanningCells: ({ col: number; row: number; colSpan: number; rowSpan?: undefined; verticalAlignment?: undefined; alignment?: undefined; } | { ...; } | { ...; })[]; }' is not assignable to type 'BaseUserConfig'.     Types of property 'columns' are incompatible.       Type '({ alignment: string; width: number; } | { alignment: string; width?: undefined; })[]' is not assignable to type 'Indexable<ColumnUserConfig>'.         'number' index signatures are incompatible.           Type '{ alignment: string; width: number; } | { alignment: string; width?: undefined; }' is not assignable to type 'ColumnUserConfig'.             Type '{ alignment: string; width: number; }' is not assignable to type 'ColumnUserConfig'.               Type '{ alignment: string; width: number; }' is not assignable to type 'CellUserConfig'.                 Types of property 'alignment' are incompatible.                   Type 'string' is not assignable to type 'Alignment | undefined'.
@tomhoad
Copy link
Author

tomhoad commented Oct 7, 2022

const config: TableUserConfig helped

@tomhoad tomhoad closed this as completed Oct 7, 2022
@aditya-manit
Copy link

Did you change anything else ? for me its still the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants