Skip to content

Conversation

@jmgasper
Copy link
Contributor

No description provided.

@jmgasper jmgasper merged commit f24738e into master Nov 28, 2025
4 of 5 checks passed
export function transformArray({ value }: { value: string }) {
return Array.isArray(value) ? value : [value];
export function transformArray({ value }: { value: unknown }) {
if (value === undefined || value === null) return undefined;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Returning undefined when value is undefined or null may lead to unexpected behavior if the caller expects an array. Consider returning an empty array instead to maintain consistent return types.

return [v];
};

return Array.isArray(value) ? value.flatMap(splitIfString) : splitIfString(value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 design]
Using flatMap here is efficient for flattening arrays, but ensure that the caller is aware that nested arrays will be flattened, which might not be the intended behavior if the input is expected to be a single-level array.

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