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

Fix (TypeScript): give datum an any type #2436

Merged
merged 5 commits into from
Aug 19, 2022
Merged

Conversation

scottrippey
Copy link
Member

What

The common props x, y, y0, and sortKey allow for "accessor" functions, like:

<VictoryLine
  data={data}
  x = {(datum) => datum.xValue}
  y = {(datum) => datum.yValue}
/>

Currently, we have the datum arg typed as object, which doesn't allow for any property access nor strong types (see #2360).

This PR allows for the type to be any. This seems like the best approach, since we currently don't know the shape of Datum, nor do we support generics with any of our components.
This will allow the above code to function properly, as well as support manually-added types (like (datum: MyData) => datum.xValue).

Copy link
Contributor

@gksander gksander left a comment

Choose a reason for hiding this comment

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

LGTM

@scottrippey scottrippey merged commit c6de69d into main Aug 19, 2022
@scottrippey scottrippey deleted the ts/data-accessor-fix branch August 19, 2022 16:40
@github-actions github-actions bot mentioned this pull request Aug 19, 2022
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.

None yet

2 participants