Skip to content

[BUG] addRow and addRows types broken in 4.1.0 #1375

@bengry

Description

@bengry

🐛 Bug Report

v4.1.0 of the library broke the [TypeScript] types of addRow and addRows by requiring a second argument (styleOption). This is however an optional argument.

Lib version: 4.1.0

Steps To Reproduce

const wb = new ExcelJS.Workbook();
const ws = wb.addWorksheet('blort');

ws.addRow([1]); // type error

The expected behaviour:

There should be no compilationn error, since the second argument is optional.

Possible solution (optional, but very helpful):

--- a/node_modules/exceljs/index.d.ts
+++ b/node_modules/exceljs/index.d.ts
@@ -1193,12 +1193,12 @@ export interface Worksheet {
 	 * Add a couple of Rows by key-value, after the last current row, using the column keys,
 	 * or add a row by contiguous Array (assign to columns A, B & C)
 	 */
-	addRow(data: any[] | any, styleOption: string): Row;
+	addRow(data: any[] | any, styleOption?: string): Row;

 	/**
 	 * Add multiple rows by providing an array of arrays or key-value pairs
 	 */
-	addRows(rows: any[], styleOption: string): void;
+	addRows(rows: any[], styleOption?: string): void;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions