Skip to content

fix(csv-stringify): allow mixed string and object columns typedef #456

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

Merged

Conversation

tusbar
Copy link
Contributor

@tusbar tusbar commented May 7, 2025

Since the code allows to specify the columns option as a mixed array of either string or ColumnOption, this updates the types accordingly.

See:

for (const column of columns) {
if (typeof column === "string") {
newcolumns.push({
key: column,
header: column,
});
} else if (
typeof column === "object" &&
column !== null &&
!Array.isArray(column)
) {
if (!column.key) {
return [
Error('Invalid column definition: property "key" is required'),
];
}
if (column.header === undefined) {
column.header = column.key;
}
newcolumns.push(column);
} else {
return [
Error("Invalid column definition: expect a string or an object"),
];
}
}
columns = newcolumns;

@tusbar tusbar force-pushed the tusbar/update-stringify-columns-type branch from 54d8a83 to a52abc4 Compare May 7, 2025 13:02
@tusbar tusbar force-pushed the tusbar/update-stringify-columns-type branch from a52abc4 to 98bf804 Compare May 7, 2025 13:04
@wdavidw wdavidw merged commit c40c0d2 into adaltas:master May 9, 2025
@tusbar tusbar deleted the tusbar/update-stringify-columns-type branch May 10, 2025 09:16
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

Successfully merging this pull request may close these issues.

2 participants