Skip to content
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

Initialization of columns Property for xxxParse(...) methods #31

Closed
tomwanzek opened this issue Nov 3, 2017 · 3 comments
Closed

Initialization of columns Property for xxxParse(...) methods #31

tomwanzek opened this issue Nov 3, 2017 · 3 comments

Comments

@tomwanzek
Copy link
Contributor

In the edge case where the to-be-parsed string passed into xxxParse(...) methods is empty, the column property of the returned parsed array is undefined.

Although this is an edge case, it seems preferable to return an empty array of column names for consistency.

(Thanks @azoson for pointing this behaviour out in DefinitelyTyped/DefinitelyTyped#21092 and DefinitelyTyped/DefinitelyTyped#21162 . cc @gustavderdrache)

@mbostock
Copy link
Member

mbostock commented Nov 3, 2017

Yep, a bug. I’d probably change the assignment to:

rows.columns = columns || [];

@tomwanzek
Copy link
Contributor Author

I just pushed a PR to save you the trouble 😄 I thought the initialization could happen right when columns is declared.

Both approaches should work, if you want me to change the PR to your fallback assignment, I could quickly change it. your call.

@tomwanzek
Copy link
Contributor Author

@mbostock I changed the PR to use the fallback approach: rows.columns = columns || [];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants