Skip to content

Commit ad532b0

Browse files
committed
fix: extract hideHeaders from destructuring to preserve explicit false
The destructuring default only fires when the property is undefined, making the options.hideHeaders ?? fallback redundant inside it. Extract to a separate const with ?? so explicit false from callers is preserved.
1 parent f4504ef commit ad532b0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib/formatters/text-table.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,14 @@ export function renderTextTable(
106106
minWidths = [],
107107
shrinkable = [],
108108
truncate = false,
109-
hideHeaders = options.hideHeaders ?? headers.every((h) => h.trim() === ""),
110109
rowSeparator = false,
111110
} = options;
112111

112+
// Auto-detect empty headers when not explicitly set by the caller.
113+
// Extracted from destructuring because `??` preserves explicit `false`.
114+
const hideHeaders =
115+
options.hideHeaders ?? headers.every((h) => h.trim() === "");
116+
113117
const border = BorderChars[borderStyle];
114118
const colCount = headers.length;
115119
if (colCount === 0) {

0 commit comments

Comments
 (0)