From 74102ab53d039cf7eef532c7567f2e7f3aa8da3f Mon Sep 17 00:00:00 2001 From: cornholio <0@mcornholio.ru> Date: Sat, 27 Oct 2018 14:14:00 +0300 Subject: [PATCH] @types/cli-table2 fixed header types Though it is not currently documented, `head` prop accepts `Cell[]`, not `string[]`. I've made PR to cli-table2 regarding this (https://github.com/jamestalmage/cli-table2/pull/53), but typings should be fixed whether it is megred or not --- types/cli-table2/cli-table2-tests.ts | 21 +++++++++++++++++++++ types/cli-table2/index.d.ts | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/types/cli-table2/cli-table2-tests.ts b/types/cli-table2/cli-table2-tests.ts index dfaed4ec33..97d8c82dbe 100644 --- a/types/cli-table2/cli-table2-tests.ts +++ b/types/cli-table2/cli-table2-tests.ts @@ -230,3 +230,24 @@ table26.push( // feel free to use colors in your content strings, column widths will be calculated correctly const table27 = new Table({ colWidths: [5], style: { head: [], border: [] } }) as Table.HorizontalTable; table27.push([/*colors.red(*/'hello'/*)*/]); + +// Header as text +const table28 = new Table({ head: ["Top Header 1", "Top Header 2"] }) as Table.HorizontalTable; +table28.push( + ['Value Row 1 Col 1', 'Value Row 1 Col 2'], + ['Value Row 2 Col 1', 'Value Row 2 Col 2'] +); + +// Header as Cells +const table29 = new Table({ head: [{content: "Top Header 1"}, {content: "Top Header 2"}] }) as Table.HorizontalTable; +table29.push( + ['Value Row 1 Col 1', 'Value Row 1 Col 2'], + ['Value Row 2 Col 1', 'Value Row 2 Col 2'] +); + +// ColSpan in header +const table30 = new Table({ head: [{content: "Top Header 1", colSpan: 2}, {content: "Top Header 3"}] }) as Table.HorizontalTable; +table30.push( + ['Value Row 1 Col 1', 'Value Row 1 Col 2', 'Value Row 1 Col 3'], + ['Value Row 2 Col 1', 'Value Row 2 Col 2', 'Value Row 2 Col 3'] +); diff --git a/types/cli-table2/index.d.ts b/types/cli-table2/index.d.ts index b216b23832..865439f000 100644 --- a/types/cli-table2/index.d.ts +++ b/types/cli-table2/index.d.ts @@ -31,7 +31,7 @@ declare namespace CliTable2 { rowHeights: Array; colAligns: HorizontalAlignment[]; rowAligns: VerticalAlignment[]; - head: string[]; + head: Cell[]; wordWrap: boolean; }