From 2867a964037f35a308c57077e032ac8d6f5959ef Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Wed, 3 Oct 2018 20:41:41 +0200 Subject: [PATCH] Enhance typings of easy-table (#29390) * Enhance typings of easy table * Use frozen colors in tests --- types/easy-table/easy-table-tests.ts | 2 ++ types/easy-table/index.d.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/types/easy-table/easy-table-tests.ts b/types/easy-table/easy-table-tests.ts index 8eba36ce6e..f5ee9efecd 100644 --- a/types/easy-table/easy-table-tests.ts +++ b/types/easy-table/easy-table-tests.ts @@ -83,11 +83,13 @@ function totalling() { function other_samples() { var t = new Table(); + var columns = Object.freeze(t.columns()); data.forEach(product => { t.cell('Product Id', product.id) t.cell('Description', product.desc) t.cell('Price, USD', product.price, Table.number(2)) + t.pushDelimeter(columns) t.newRow() }) diff --git a/types/easy-table/index.d.ts b/types/easy-table/index.d.ts index f75d74861b..0ee1863c4e 100644 --- a/types/easy-table/index.d.ts +++ b/types/easy-table/index.d.ts @@ -53,7 +53,7 @@ declare class EasyTable { * * @returns {Table} `this` */ - public newRow(): EasyTable; + public newRow(): this; /** * Write cell in the current row @@ -63,7 +63,7 @@ declare class EasyTable { * @param {Function} [printer] - Printer function to format the value * @returns {Table} `this` */ - public cell(col: string, val: T, printer?: CellPrinter): EasyTable; + public cell(col: string, val: T, printer?: CellPrinter): this; /** * Get list of columns in printing order @@ -92,7 +92,7 @@ declare class EasyTable { * @param {String[]} [cols] * @returns {Table} `this` */ - public pushDelimeter(cols?: string[]): EasyTable; + public pushDelimeter(cols?: ReadonlyArray): this; /** * Compute all totals and yield the results to `cb` @@ -115,14 +115,14 @@ declare class EasyTable { * @param {Function|string[]} [cmp] - Either compare function or a list of columns to sort on * @returns {Table} `this` */ - public sort(cmp?: string[]): EasyTable; + public sort(cmp?: ReadonlyArray): this; /** * Sort the table * * @param {Function|string[]} [cmp] - Either compare function or a list of columns to sort on * @returns {Table} `this` */ - public sort(cmp?: CompareFunction): EasyTable; + public sort(cmp?: CompareFunction): this; /** * Add a total for the column @@ -131,7 +131,7 @@ declare class EasyTable { * @param {Object} [opts] * @returns {Table} `this` */ - public total(col: string, opts?: TotalOptions): EasyTable; + public total(col: string, opts?: TotalOptions): this; /** * Predefined helpers for totals */